From d08c29c0830531391b7c696a7ecafe5ad3f302cb Mon Sep 17 00:00:00 2001 From: Micha Rosenbaum Date: Sat, 14 Jan 2017 16:12:24 +0100 Subject: [PATCH] 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 --- coffee/script.coffee | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/coffee/script.coffee b/coffee/script.coffee index 63fb88a..b0c664e 100644 --- a/coffee/script.coffee +++ b/coffee/script.coffee @@ -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)