Changeset 303 for Dev/branches/rest-dojo-ui/server/classes/Auth.php
- Timestamp:
- 03/04/12 15:48:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/rest-dojo-ui/server/classes/Auth.php
r274 r303 7 7 public static function register($email, $password) { 8 8 $user_results = User::get(array("email" => $email)); 9 if ( !empty($user_results)) {9 if (!empty($user_results)) { 10 10 throw new Exception("User with email $email already exists."); 11 11 } 12 12 $salt = rand(); 13 $user = new User(null,$email,sha1($password.$salt),$salt); 13 $user = new User(null, array( 14 'email' => $email, 15 'passwordHash' => sha1($password . $salt), 16 'passwordSalt' => $salt)); 14 17 $user->save(); 15 18 return $user; 16 19 } 17 20 18 21 public static function login($email, $password) { 19 22 $user_results = User::get(array("email" => $email)); … … 22 25 } 23 26 $user = $user_results[0]; 24 if (sha1($password .$user->passwordSalt) != $user->passwordHash) {27 if (sha1($password . $user->passwordSalt) != $user->passwordHash) { 25 28 throw new Exception("Wrong password."); 26 29 } … … 35 38 return $user_results[0]; 36 39 } 37 40 38 41 } 39 42
Note: See TracChangeset
for help on using the changeset viewer.