summaryrefslogtreecommitdiff
path: root/public/assets/js/lib
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-14 19:53:31 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-14 19:53:31 +0100
commit3a42fe7ad797a6f9cf747d2d358015ac992765a7 (patch)
tree169c2123067abc677b9e3fa8d19142bd3af3338e /public/assets/js/lib
parentd776e6aa7d1e458ef050c016a4c285aa5887c5f0 (diff)
change password - profile stuff
Diffstat (limited to 'public/assets/js/lib')
-rw-r--r--public/assets/js/lib/sdk/auth.js7
-rw-r--r--public/assets/js/lib/views/index/hootbox.js2
-rw-r--r--public/assets/js/lib/views/profile/profile_edit.js16
3 files changed, 22 insertions, 3 deletions
diff --git a/public/assets/js/lib/sdk/auth.js b/public/assets/js/lib/sdk/auth.js
index c720292..0b49449 100644
--- a/public/assets/js/lib/sdk/auth.js
+++ b/public/assets/js/lib/sdk/auth.js
@@ -70,6 +70,7 @@ var auth = (function(){
$.ajax({
method: 'put',
url: '/api/checkin',
+ headers: { "csrf-token": $("[name=_csrf]").attr("value") },
success: function(data){
if (data && data.user && data.user.id !== -1) {
auth.set_user(data.user)
@@ -77,7 +78,11 @@ var auth = (function(){
return
}
opt.error()
- }
+ },
+ error: function(){
+ window.location.href = '/login'
+ opt.error()
+ },
})
}
diff --git a/public/assets/js/lib/views/index/hootbox.js b/public/assets/js/lib/views/index/hootbox.js
index 85fd51e..2338153 100644
--- a/public/assets/js/lib/views/index/hootbox.js
+++ b/public/assets/js/lib/views/index/hootbox.js
@@ -23,7 +23,7 @@ var HootBox = FormView.extend({
},
parse: function(comment){
- var t = this.template.replace(/{{username}}/g, profile_image(comment.username))
+ var t = this.template.replace(/{{image}}/g, profile_image(comment.username))
.replace(/{{username}}/g, comment.username)
.replace(/{{comment}}/g, tidy_urls(comment.comment, true))
return t
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