diff options
author | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-12 11:17:48 +0200 |
---|---|---|
committer | Marko Pušnik <marko.pusnik@guru.si> | 2015-10-12 11:17:48 +0200 |
commit | 3c03af39297f47af09def0cacba5190b0081a718 (patch) | |
tree | 545bf3f46286fc849dac15bebd1f52d93466fbc7 /js/codeq | |
parent | c1a76a0e4e8bebe3823a625a357e73a3d666bcbd (diff) |
signUp: added name and email
Diffstat (limited to 'js/codeq')
-rw-r--r-- | js/codeq/comms.js | 4 | ||||
-rw-r--r-- | js/codeq/profile.js | 60 |
2 files changed, 33 insertions, 31 deletions
diff --git a/js/codeq/comms.js b/js/codeq/comms.js index 54f5d24..ab168ff 100644 --- a/js/codeq/comms.js +++ b/js/codeq/comms.js @@ -367,10 +367,10 @@ return this.send({'action': 'logout'}); }, - 'signup': function (username, password) { + 'signup': function (username, name, email, password) { var myself = this, performSignUp = function () { - return myself.send({'action': 'signup', 'username': username, 'password': password}); + return myself.send({'action': 'signup', 'username': username, 'name': name, 'email': email, 'password': password}); }; if (socket) return performSignUp(); diff --git a/js/codeq/profile.js b/js/codeq/profile.js index be0bb1e..687a3c7 100644 --- a/js/codeq/profile.js +++ b/js/codeq/profile.js @@ -4,37 +4,39 @@ (function(){
- codeq.profile = {
-
- 'signup': function () {
- var jqUsername = $("#modalSignUpUsername"),
- jqPassword = $("#modalSignUpPassword"),
- jqVerify = $("#modalSignUpVerify");
+ $('#formSignUp').submit(function(event) {
+ console.log($(this).serialize());
+ var jqUsername = $("#modalSignUpUsername"),
+ jqName = $("#modalSignUpName"),
+ jqEmail = $("#modalSignUpEmail"),
+ jqPassword = $("#modalSignUpPassword"),
+ jqVerify = $("#modalSignUpVerify");
- if (jqUsername.val() == "" || jqPassword.val() == "" || jqVerify.val() == "") {
- alert('Some fields are empty.');
- }
- else if (jqPassword.val() != jqVerify.val()) {
- alert('Passwords do not match.');
- }
- else {
- codeq.comms.signup(jqUsername.val(), jqPassword.val())
- .then(function (data) {
- //back to login
- $('#modalSignUp').modal('hide');
- alert('Welcome '+ jqUsername.val() +'. Thanks for signing up.');
- $('#modalLogIn').modal('show');
- //assume user wants to sign-in with signed username
- $("#username").val(jqUsername.val());
- //clear
- jqUsername.val('');
- jqPassword.val('');
- jqVerify.val('');
- })
- .done();
- }
+ if (jqPassword.val() != jqVerify.val()) {
+ alert('Passwords do not match.');
+ }
+ else {
+ codeq.comms.signup(jqUsername.val(), jqName.val(), jqEmail.val(), jqPassword.val())
+ .then(function (data) {
+ //back to login
+ $('#modalSignUp').modal('hide');
+ alert('Welcome '+ jqUsername.val() +'. Thanks for signing up.');
+ $('#modalLogIn').modal('show');
+ //assume user wants to sign-in with signed username
+ $("#username").val(jqUsername.val());
+ //clear
+ jqUsername.val('');
+ jqName.val('');
+ jqEmail.val('');
+ jqPassword.val('');
+ jqVerify.val('');
+ })
+ .done();
+ }
+ event.preventDefault(); // Prevent the form from submitting via the browser.
+ });
- },
+ codeq.profile = {
'changePassword': function () {
var jqNew = $("#modalChangePasswordNew"),
|