1
0
Fork 0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-11-09 14:40:05 +00:00

Add function to show the edit encryption password form

showEditEncPWForm() is adapted from showForm(num) to edit and create
passwords. It binds a click event handler to the primary button, that
checks if the current password is correct and if the new password is
entered twice.

If all validations succeed, the entered password is used as the
encryption password and the users data is updated with this new
password.

Issue: https://github.com/Luzifer/cloudkeys-go/issues/10
This commit is contained in:
Micha Rosenbaum 2017-01-14 16:12:24 +01:00
parent f1ee8fb42b
commit d08c29c083

View file

@ -282,6 +282,38 @@ class CloudKeys
return success
showEditEncPWForm: () ->
$('#editEncPWDialog input').val('')
$('#editEncPWDialog .hide').removeClass('hide')
$('#editEncPWDialog').modal({})
$('#editEncPWDialog .btn-primary').unbind('click').click =>
$('#editEncPWDialog .has-error').removeClass('has-error')
confirmation = confirm('Do you really want to update your encryption password?')
if confirmation isnt true
return
if $('#editEncPW_current_password').val() isnt @password
$('#editEncPW_current_password').parent().addClass('has-error')
return
new_password = $('#editEncPW_password').val()
if new_password is undefined or new_password is ''
$('#editEncPW_password').parent().addClass('has-error')
return
if new_password isnt $('#editEncPW_repeat_password').val()
$('#editEncPW_password, #editEncPW_repeat_password').parent().addClass('has-error')
return
@password = new_password
@updateData =>
$('#formEncPWClose').click()
return
window.CloudKeys = new CloudKeys()
$('#importLink').click =>
$('#importContainer').toggle(500)