From 50bbd4a6a7294546c0fe3c455f4c728e5d0701d0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 30 Sep 2011 18:26:21 -0400 Subject: Move username validation from the Users controller to the Auth model. --- src/controllers/Users.class.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/controllers/Users.class.php') diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php index c30461f..1d947e1 100644 --- a/src/controllers/Users.class.php +++ b/src/controllers/Users.class.php @@ -8,8 +8,6 @@ Router::register('users' , 'Users', 'index_dir'); Router::register('users/*' , 'Users', 'individual'); class Users extends Controller { - public static $illegal_names = array('', 'new', 'index'); - // Index Views /////////////////////////////////////////////// public function index($routed, $remainder) { @@ -143,7 +141,7 @@ class Users extends Controller { $vars['errors'] = array(); if ($db->getUID($vars['username'])!==false) $vars['errors'][] = 'user exists'; - if (in_array($vars['username'], self::$illegal_names)) + if (!Auth::isNameLegal($vars['username'])) $vars['errors'][] = 'illegal name'; $matches = ($vars['password1'] == $vars['password2']); if (!$matches) { @@ -187,11 +185,9 @@ class Users extends Controller { if (isset($_POST['auth_name'])) { $new_name = $_POST['auth_name']; if ($new_name != $username) { - if (!in_array($new_name, $this->illegal_names)) { - $changed_name = $user->setName($new_name); - $username = $user->getName(); - $vars['changed name'] = $changed_name; - } + $changed_name = $user->setName($new_name); + $username = $user->getName(); + $vars['changed name'] = $changed_name; } } -- cgit v1.2.3-54-g00ecf