diff options
author | friendica <info@friendica.com> | 2012-08-16 00:51:03 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-08-16 00:51:03 -0700 |
commit | eb911443aaee63f414cd95de4dabf60e2f14a994 (patch) | |
tree | 7c8eb42e2602b572f430474648aec611f0c20c47 | |
parent | 5b547ae991624924c0ef11dbe36ae57f5ec2182b (diff) | |
download | volse-hubzilla-eb911443aaee63f414cd95de4dabf60e2f14a994.tar.gz volse-hubzilla-eb911443aaee63f414cd95de4dabf60e2f14a994.tar.bz2 volse-hubzilla-eb911443aaee63f414cd95de4dabf60e2f14a994.zip |
more zregister cleanup and theme separation
-rw-r--r-- | include/account.php | 27 | ||||
-rw-r--r-- | include/js_strings.php | 2 | ||||
-rw-r--r-- | js/main.js | 11 | ||||
-rw-r--r-- | mod/zregister.php | 51 | ||||
-rw-r--r-- | view/js/mod_zregister.js | 31 | ||||
-rw-r--r-- | view/tpl/js_strings.tpl | 2 |
6 files changed, 74 insertions, 50 deletions
diff --git a/include/account.php b/include/account.php index 91891ab23..652048e29 100644 --- a/include/account.php +++ b/include/account.php @@ -12,7 +12,8 @@ function check_account_email($email) { $result = array('error' => false, 'message' => ''); - // Caution: empty email isn't counted as an error in this function. Check emptiness separately. + // Caution: empty email isn't counted as an error in this function. + // Check for empty value separately. if(! strlen($email)) return $result; @@ -32,10 +33,25 @@ function check_account_email($email) { if($result['message']) $result['error'] = true; - return $result; + $arr = array('email' => $email, 'result' => $result); + call_hooks('check_account_email', $arr); + + return $arr['result']; } +function check_account_password($password) { + $result = array('error' => false, 'message' => ''); + + // The only validation we perform by default is pure Javascript to + // check minimum length and that both entered passwords match. + // Use hooked functions to perform complexity requirement checks. + + $arr = array('password' => $password, 'result' => $result); + call_hooks('check_account_password', $arr); + return $arr['result']; + +} function create_account($arr) { @@ -77,6 +93,13 @@ function create_account($arr) { return $result; } + $password_result = check_account_password($password); + + if(! $password_result['error']) { + $result['message'] = $password_result['message']; + return $result; + } + $password_encoded = hash('whirlpool',$password); $r = q("INSERT INTO account diff --git a/include/js_strings.php b/include/js_strings.php index 8de789b33..e9892ea72 100644 --- a/include/js_strings.php +++ b/include/js_strings.php @@ -6,6 +6,8 @@ function js_strings() { '$comment' => t('Comment'), '$showmore' => t('show more'), '$showfewer' => t('show fewer'), + '$pwshort' => t("Password too short"), + '$pwnomatch' => t("Passwords do not match"), '$t01' => ((t('timeago.prefixAgo') != 'timeago.prefixAgo') ? t('timeago.prefixAgo') : 'null'), '$t02' => ((t('timeago.suffixAgo') != 'timeago.suffixAgo') ? t('timeago.suffixAgo') : 'null'), diff --git a/js/main.js b/js/main.js index b1ebd80e0..e33f21940 100644 --- a/js/main.js +++ b/js/main.js @@ -851,3 +851,14 @@ $("abbr.wall-item-ago-time").timeago(); }); + function zFormError(elm,x) { + if(x) { + $(elm).addClass("zform-error"); + $(elm).removeClass("zform-ok"); + } + else { + $(elm).addClass("zform-ok"); + $(elm).removeClass("zform-error"); + } + } + diff --git a/mod/zregister.php b/mod/zregister.php index 2cde25469..da3bc9f36 100644 --- a/mod/zregister.php +++ b/mod/zregister.php @@ -11,55 +11,10 @@ function zregister_init(&$a) { json_return_and_die($result); } - $pw1 = t("Password too short"); - $pw2 = t("Passwords do not match"); - - $a->page['htmlhead'] .= <<< EOT -<script> - function zFormError(elm,x) { - if(x) { - $(elm).addClass("zform-error"); - $(elm).removeClass("zform-ok"); - } - else { - $(elm).addClass("zform-ok"); - $(elm).removeClass("zform-error"); - } + if($cmd === 'password_check.json') { + $result = check_account_password($_REQUEST['password']); + json_return_and_die($result); } - $(document).ready(function() { - $("#zregister-email").blur(function() { - var zreg_email = $("#zregister-email").val(); - $.get("zregister/email_check.json?f=&email=" + encodeURIComponent(zreg_email),function(data) { - $("#zregister-email-feedback").html(data.message); - zFormError("#zregister-email-feedback",data.error); - }); - }); - $("#zregister-password").blur(function() { - if(($("#zregister-password").val()).length < 6 ) { - $("#zregister-password-feedback").html("$pw1"); - zFormError("#zregister-password-feedback",true); - } - else { - $("#zregister-password-feedback").html(""); - zFormError("#zregister-password-feedback",false); - } - }); - $("#zregister-password2").blur(function() { - if($("#zregister-password").val() != $("#zregister-password2").val()) { - $("#zregister-password2-feedback").html("$pw2"); - zFormError("#zregister-password2-feedback",true); - } - else { - $("#zregister-password2-feedback").html(""); - zFormError("#zregister-password2-feedback",false); - } - }); - }); - -</script> - -EOT; - } diff --git a/view/js/mod_zregister.js b/view/js/mod_zregister.js new file mode 100644 index 000000000..c9935e47f --- /dev/null +++ b/view/js/mod_zregister.js @@ -0,0 +1,31 @@ + $(document).ready(function() { + $("#zregister-email").blur(function() { + var zreg_email = $("#zregister-email").val(); + $.get("zregister/email_check.json?f=&email=" + encodeURIComponent(zreg_email),function(data) { + $("#zregister-email-feedback").html(data.message); + zFormError("#zregister-email-feedback",data.error); + }); + }); + $("#zregister-password").blur(function() { + if(($("#zregister-password").val()).length < 6 ) { + $("#zregister-password-feedback").html(aStr['pwshort']); + zFormError("#zregister-password-feedback",true); + } + else { + $("#zregister-password-feedback").html(""); + zFormError("#zregister-password-feedback",false); + } + }); + $("#zregister-password2").blur(function() { + if($("#zregister-password").val() != $("#zregister-password2").val()) { + $("#zregister-password2-feedback").html(aStr['pwnomatch']); + zFormError("#zregister-password2-feedback",true); + } + else { + $("#zregister-password2-feedback").html(""); + zFormError("#zregister-password2-feedback",false); + } + }); + }); + +</script> diff --git a/view/tpl/js_strings.tpl b/view/tpl/js_strings.tpl index db3bb7d7c..9e5fb77bd 100644 --- a/view/tpl/js_strings.tpl +++ b/view/tpl/js_strings.tpl @@ -7,6 +7,8 @@ 'comment' : '$comment', 'showmore' : '$showmore', 'showfewer' : '$showfewer', + 'pwshort' : '$pwshort', + 'pwnomatch' : 'pwnomatch', 't01' : $t01, 't02' : $t02, |