X-Git-Url: http://git.maemo.org/git/?p=speedfreak;a=blobdiff_plain;f=Server%2Fapplication%2Fmodels%2Fuser.php;fp=Server%2Fapplication%2Fmodels%2Fuser.php;h=4440cdfa11fe4bd6ce8d45f1a58910419b26b69b;hp=95daac7d11753f271a02e82f945eef602a7b8721;hb=2c157b77bd08e659c5a7358891819804abfcfde2;hpb=9cddbaf57a215186fee6ed1345adf2a1d066d921 diff --git a/Server/application/models/user.php b/Server/application/models/user.php index 95daac7..4440cdf 100644 --- a/Server/application/models/user.php +++ b/Server/application/models/user.php @@ -53,25 +53,25 @@ class User_Model extends Model { * @return bool Returns True if operation was successfull and exception otherwise */ private function register($username, $password, $email){ - // hash password + // hash password $password = $this->hash($password); - + // @todo I can't seem to get query working when password binding has '' around it like others if ($this->user_exists($username, $email)==false) - return $this->db->query("INSERT into users SET username = '?', password = ?, email = '?'", - $username, $password, $email); + return $this->db->query("INSERT into users SET username = '?', password = ?, email = '?'", + $username, $password, $email); else return false; } - + /* * Hash password supplied by user using salt stored in config file - * + * * @param string $password Password in plain text format * @return string Returns string containing hash generated from password */ private function hash($password){ - return sha1($password.Kohana::config('api.salt')); + return sha1($password.Kohana::config('api.salt')); } /* @@ -82,16 +82,16 @@ class User_Model extends Model { * @return bool Returns True if user exists and false otherwise */ private function user_exists($username, $email){ - if ($this->db->query("SELECT id FROM users WHERE username = '?' OR email = '?'", + if ($this->db->query("SELECT id FROM users WHERE username = '?' OR email = '?'", $username, $email)->count()>0) return true; else - return false; + return false; } - + /* * Check if supplied credentials are valid - * + * * @param string $username Username * @param string $password Password in plain text format * @return bool True if credentials match and false if supplied credentials are invalid @@ -99,7 +99,7 @@ class User_Model extends Model { public function login($username, $password){ // hash password $password = $this->hash($password); - + if ($this->db->query("SELECT id FROM users WHERE username = ? AND password = ?", $username, $password)->count()>0) return true;