From 3a42fe7ad797a6f9cf747d2d358015ac992765a7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 14 Dec 2017 19:53:31 +0100 Subject: change password - profile stuff --- public/assets/js/lib/views/profile/profile_edit.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'public/assets/js/lib/views/profile/profile_edit.js') diff --git a/public/assets/js/lib/views/profile/profile_edit.js b/public/assets/js/lib/views/profile/profile_edit.js index a887357..e50a7c0 100644 --- a/public/assets/js/lib/views/profile/profile_edit.js +++ b/public/assets/js/lib/views/profile/profile_edit.js @@ -64,6 +64,7 @@ var ProfileForm = FormView.extend({ canvas.height = h ctx.drawImage(img, 0, 0, w, h) var dataURI = canvas.toDataURL('image/jpeg', 0.85) + this.avatarBlob = dataUriToBlob(dataURI) this.$("#profile-avatar-embed").show().attr("src", dataURI).css("width", w/2) }, @@ -71,6 +72,18 @@ var ProfileForm = FormView.extend({ this.$(".oldpassword").css('display', 'flex') }, + serialize: function(){ + var fd = this.__super__.serialize.call(this) + var oldpw = this.$("[name=oldpassword]").val() + var pw = this.$("[name=newpassword]").val() + var pw2 = this.$("[name=newpassword2]").val() + fd.delete('avatar') + if (this.avatarBlob) { + fd.append("avatar", this.avatarBlob) + } + return fd + }, + validate: function(){ var errors = [] var oldpw = this.$("[name=oldpassword]").val() @@ -89,6 +102,7 @@ var ProfileForm = FormView.extend({ if (data.error) { return alert(data.error) } - window.location.href = "/details/" + data.id + auth.set_user(data.user) + window.location.href = "/profile" } }) \ No newline at end of file -- cgit v1.2.3-70-g09d2