Bug fix: test username's length (max 25) when registering (preventing problem with database
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@155 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
fc5091f407
commit
e530ffa24f
2 changed files with 16 additions and 0 deletions
|
@ -40,6 +40,10 @@ if (isset($_POST['submitted'])) {
|
||||||
} elseif ($userservice->getUserByUsername($posteduser)) {
|
} elseif ($userservice->getUserByUsername($posteduser)) {
|
||||||
$tplVars['error'] = T_('This username already exists, please make another choice.');
|
$tplVars['error'] = T_('This username already exists, please make another choice.');
|
||||||
|
|
||||||
|
// Check if username is valid (length, authorized characters)
|
||||||
|
} elseif (!$userservice->isValidUsername($posteduser)) {
|
||||||
|
$tplVars['error'] = T_('This username is not valid (too long, forbidden characters...), please make another choice.');
|
||||||
|
|
||||||
// Check if e-mail address is valid
|
// Check if e-mail address is valid
|
||||||
} elseif (!$userservice->isValidEmail($_POST['email'])) {
|
} elseif (!$userservice->isValidEmail($_POST['email'])) {
|
||||||
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
|
$tplVars['error'] = T_('E-mail address is not valid. Please try again.');
|
||||||
|
|
|
@ -389,6 +389,18 @@ class UserService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isValidUsername($username) {
|
||||||
|
if (strlen($username) > 24) {
|
||||||
|
// too long usernames are cut by database and may cause bugs when compared
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function isValidEmail($email) {
|
function isValidEmail($email) {
|
||||||
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email)) {
|
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$", $email)) {
|
||||||
list($emailUser, $emailDomain) = split("@", $email);
|
list($emailUser, $emailDomain) = split("@", $email);
|
||||||
|
|
Loading…
Reference in a new issue