summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/profile.js50
1 files changed, 30 insertions, 20 deletions
diff --git a/js/codeq/profile.js b/js/codeq/profile.js
index 687a3c7..2759be3 100644
--- a/js/codeq/profile.js
+++ b/js/codeq/profile.js
@@ -18,6 +18,8 @@
else {
codeq.comms.signup(jqUsername.val(), jqName.val(), jqEmail.val(), jqPassword.val())
.then(function (data) {
+ if (data.code !== 0) throw new Error('Signup failed, code: ' + data.code + ', message: ' + data.message);
+
//back to login
$('#modalSignUp').modal('hide');
alert('Welcome '+ jqUsername.val() +'. Thanks for signing up.');
@@ -31,34 +33,42 @@
jqPassword.val('');
jqVerify.val('');
})
+ .fail(function (reason) {
+ codeq.log.error('Signup failed: ' + reason, reason);
+ alert('Signup failed: ' + reason);
+ })
.done();
}
event.preventDefault(); // Prevent the form from submitting via the browser.
});
- codeq.profile = {
+ $('#formChangePassword').submit(function(event) {
+ var jqNew = $("#modalChangePasswordNew"),
+ jqVerify = $("#modalChangePasswordVerify");
- 'changePassword': function () {
- var jqNew = $("#modalChangePasswordNew"),
- jqVerify = $("#modalChangePasswordVerify");
+ if (jqNew.val() != jqVerify.val()) {
+ alert('Passwords do not match.');
+ }
+ else {
+ codeq.comms.changePassword(jqNew.val())
+ .then(function (data) {
+ if (data.code !== 0) throw new Error('Password change failed, code: ' + data.code + ', message: ' + data.message);
- if (jqNew.val() == "" || jqVerify.val() == "") {
- alert('Some fields are empty.');
- }
- else if (jqNew.val() != jqVerify.val()) {
- alert('Passwords do not match.');
- }
- else {
- codeq.comms.changePassword(jqNew.val())
- .then(function (data) {
- $('#modalChangePassword').modal('hide');
- jqNew.val('');
- jqVerify.val('');
- alert('Password changed.');
- })
- .done();
- }
+ $('#modalChangePassword').modal('hide');
+ jqNew.val('');
+ jqVerify.val('');
+ alert('Password changed.');
+ })
+ .fail(function (reason) {
+ codeq.log.error('Password change failed: ' + reason, reason);
+ alert('Password change failed: ' + reason);
+ })
+ .done();
}
+ event.preventDefault(); // Prevent the form from submitting via the browser.
+ });
+
+ codeq.profile = {
};
codeq.globalStateMachine.register('profile',{