Fixed profile edit page issue
This commit is contained in:
@@ -57,28 +57,24 @@ var userProfile = {
|
||||
user.current.new_password = value
|
||||
})
|
||||
}),
|
||||
m('input.third#oPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
style: userProfile.changePassword ?
|
||||
'display: inline-block;'
|
||||
: 'display: none;',
|
||||
placeholder: 'Password Lama',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.old_password = value
|
||||
userProfile.changePassword ? [
|
||||
m('input.third#oPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
placeholder: 'Password Lama',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.old_password = value
|
||||
})
|
||||
}),
|
||||
m('input.third#rNPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
placeholder: 'Ulang Password Baru',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.re_new_password = value
|
||||
})
|
||||
})
|
||||
}),
|
||||
m('input.third#rNPwd', {
|
||||
type: 'password',
|
||||
required: 'required',
|
||||
style: userProfile.changePassword ?
|
||||
'display: inline-block;'
|
||||
: 'display: none;',
|
||||
placeholder: 'Ulang Password Baru',
|
||||
oninput: m.withAttr('value', function(value) {
|
||||
user.current.re_new_password = value
|
||||
})
|
||||
})
|
||||
] : null
|
||||
])
|
||||
]),
|
||||
m('tr', [
|
||||
|
||||
@@ -66,25 +66,30 @@ var user = {
|
||||
})
|
||||
},
|
||||
editProfile: function() {
|
||||
if (_.isEqual(user.current.re_new_password, user.current.new_password)) {
|
||||
_.unset(user.current, 're_new_password')
|
||||
return m.request({
|
||||
method: 'POST',
|
||||
url: '/edit-profile/' + window.location.search,
|
||||
data: user.current,
|
||||
withCredentials: true,
|
||||
headers: {client: 'api', 'x-query': window.location.search}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.status == true) {
|
||||
user.logout()
|
||||
}
|
||||
window.message = response.message
|
||||
})
|
||||
if (!_.isNil(user.current.old_password) && !_.isNil(user.current.re_new_password)) {
|
||||
if (_.isEqual(user.current.re_new_password, user.current.new_password)) {
|
||||
_.unset(user.current, 're_new_password')
|
||||
} else {
|
||||
window.message = 'Password baru tidak sama'
|
||||
m.redraw()
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
window.message = 'Password baru tidak sama'
|
||||
m.redraw()
|
||||
_.unset(user.current, 'new_password')
|
||||
}
|
||||
return m.request({
|
||||
method: 'POST',
|
||||
url: '/edit-profile/' + window.location.search,
|
||||
data: user.current,
|
||||
withCredentials: true,
|
||||
headers: {client: 'api', 'x-query': window.location.search}
|
||||
})
|
||||
.then(function(response) {
|
||||
if (response.status == true) {
|
||||
user.logout()
|
||||
}
|
||||
window.message = response.message
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user