summaryrefslogtreecommitdiffstats
path: root/hosted
diff options
context:
space:
mode:
authorTorsten Grote <grote@kolabsys.com>2012-07-10 13:59:40 +0200
committerTorsten Grote <grote@kolabsys.com>2012-07-10 13:59:40 +0200
commit16026f336093839a8dc3fdd9559e1700ef295613 (patch)
tree3bbd4304de95dae0e88518df9e98e6825856705b /hosted
parent34bfb106f2164400882fabb54e92036bf1466cea (diff)
downloadwebadmin-16026f336093839a8dc3fdd9559e1700ef295613.tar.gz
allow for dynamic user type switching when signing up
Diffstat (limited to 'hosted')
-rw-r--r--hosted/js/kolab_hosted.js47
1 files changed, 37 insertions, 10 deletions
diff --git a/hosted/js/kolab_hosted.js b/hosted/js/kolab_hosted.js
index 577aa5c..7bbc35c 100644
--- a/hosted/js/kolab_hosted.js
+++ b/hosted/js/kolab_hosted.js
@@ -21,6 +21,42 @@
+--------------------------------------------------------------------------+
*/
+// overwrite user_save() function
+kadm.user_save = function(reload, section)
+{
+ var data = kadm.serialize_form('#'+this.env.form_id);
+
+ // check email address
+ if(!isValidEmailAddress(data.mailalternateaddress)) {
+ // TODO use translatable error message
+ kadm.display_message('Please provide a valid email adress as this is where your password will be sent to.', 'error');
+ kadm.form_value_error('mailalternateaddress');
+ return;
+ }
+
+ // check password
+ if (data.userpassword != data.userpassword2) {
+ kadm.display_message('user.password.mismatch', 'error');
+ kadm.form_value_error('userpassword2');
+ return;
+ }
+ delete data['userpassword2'];
+
+ if (!kadm.check_required_fields(data)) {
+ kadm.display_message('form.required.empty', 'error');
+ return;
+ }
+
+ kadm.http_post('signup.add_user', {data: data});
+};
+
+kadm.change_user_type = function()
+{
+ var data = kadm.serialize_form('#'+this.env.form_id);
+
+ kadm.http_post('signup.default', {data: data});
+};
+
kadm.check_user_availability = function()
{
// get form data and build new email address
@@ -50,15 +86,6 @@ kadm.check_user_availability_response = function(response)
update_user_info(msg);
};
-kadm.user_signup = function()
-{
- if(isValidEmailAddress($('input[name="mailalternateaddress"]').val())) {
- kadm.user_save();
- } else{
- kadm.display_message('Please provide a valid email adress as this is where your password will be sent to.', 'error');
- }
-}
-
function update_user_info(msg)
{
@@ -78,7 +105,7 @@ function update_user_info(msg)
} else {
$('input[type="button"]').attr("disabled", "disabled");
}
-}
+};
function isValidEmailAddress(emailAddress) {
var pattern = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i);