Browse Source

add login check by regular expression

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/trunk@12 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
ejikharev 16 years ago
parent
commit
017d1c2cc9
  1. 12
      User.class.php

12
User.class.php

@ -16,15 +16,19 @@ class User
static function login($login, $password) static function login($login, $password)
{ {
if (empty($login)) {
if (empty($login) || empty($password)) {
return false; return false;
} }
if (! self::$user = self::getByLogin($login) ) {
if(!preg_match("/^[a-z0-9_-]{3,20}$/i", $login)) {
return false; return false;
} }
if (self::$user->password != md5($password)) {
if (!self::$user = self::getByLogin(strtolower($login)) ) {
return false;
}
if (self::$user->pass != $password) {
return false; return false;
} }
@ -76,7 +80,7 @@ class User
static function getHash() static function getHash()
{ {
return md5(self::$user->id.'hckrz'.self::$user->login.'mst'.self::$user->password.'dai');
return md5(self::$user->id.'hckrz'.self::$user->login.'mst'.self::$user->pass.'dai');
} }
static function getInfo() static function getInfo()

Loading…
Cancel
Save