Better use of Nickname validation functions

Nickname verifications on registration and updates for profiles (not yet
groups) have been improved.

Minor bugs in RegisterAction were also fixed, where multiple forms would
be outputed because the function did not return after showForm(). This
will be solved more permanently with throwing exceptions in the future.
This commit is contained in:
Mikael Nordfeldth
2013-10-16 14:58:22 +02:00
parent 38a69b5597
commit db7ef52d13
10 changed files with 58 additions and 235 deletions

View File

@@ -237,7 +237,7 @@ function common_check_user($nickname, $password)
if (common_is_email($nickname)) {
$user = User::getKV('email', common_canonical_email($nickname));
} else {
$user = User::getKV('nickname', common_canonical_nickname($nickname));
$user = User::getKV('nickname', Nickname::normalize($nickname));
}
if (!empty($user)) {
@@ -2283,8 +2283,11 @@ function common_url_to_nickname($url)
function common_nicknamize($str)
{
$str = preg_replace('/\W/', '', $str);
return strtolower($str);
try {
return Nickname::normalize($str);
} catch (NicknameException $e) {
return null;
}
}
function common_perf_counter($key, $val=null)