@@ -8,14 +8,14 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace Core\Helpers; |
| 10 | 10 | |
| 11 | -class Hash{ |
|
| 11 | +class Hash { |
|
| 12 | 12 | /** |
| 13 | 13 | * Receives a string password and hashes it. |
| 14 | 14 | * |
| 15 | 15 | * @param string $password |
| 16 | 16 | * @return string $hash |
| 17 | 17 | */ |
| 18 | - public static function hash($password){ |
|
| 18 | + public static function hash($password) { |
|
| 19 | 19 | // return (string)password_hash($password, PASSWORD_DEFAULT); |
| 20 | 20 | return sha1(md5($password)); |
| 21 | 21 | } |
@@ -27,8 +27,8 @@ discard block |
||
| 27 | 27 | * @param string $hash |
| 28 | 28 | * @return boolean If the hash was generated from the password |
| 29 | 29 | */ |
| 30 | - public static function checkHash($string, $hash){ |
|
| 31 | - if( password_verify( $string, $hash ) ){ |
|
| 30 | + public static function checkHash($string, $hash) { |
|
| 31 | + if (password_verify($string, $hash)) { |
|
| 32 | 32 | return true; |
| 33 | 33 | } |
| 34 | 34 | return false; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | return isset($_SESSION['user']['user_id']); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | - public function attempt(string $loginField,string $password) |
|
| 28 | + public function attempt(string $loginField, string $password) |
|
| 29 | 29 | { |
| 30 | 30 | $user = UserDataAccess::getUserLoginField($loginField); |
| 31 | 31 | if (!$user) { |
@@ -35,17 +35,17 @@ discard block |
||
| 35 | 35 | ]; |
| 36 | 36 | } |
| 37 | 37 | $setting = Config::get('settings.auth'); |
| 38 | - if($setting['2step']){ |
|
| 38 | + if ($setting['2step']) { |
|
| 39 | 39 | $this->twoStepAuth(); |
| 40 | - }else{ |
|
| 41 | - if ($this->checkPass($password,$user->password)) { |
|
| 40 | + }else { |
|
| 41 | + if ($this->checkPass($password, $user->password)) { |
|
| 42 | 42 | $_SESSION['user']['user_id'] = $user->id; |
| 43 | 43 | $_SESSION['user']['mobile'] = $user->mobile; |
| 44 | 44 | return [ |
| 45 | 45 | 'type'=>'success', |
| 46 | 46 | 'message'=> 'Logined', |
| 47 | 47 | ]; |
| 48 | - }else{ |
|
| 48 | + }else { |
|
| 49 | 49 | return [ |
| 50 | 50 | 'type'=>'error', |
| 51 | 51 | 'message'=> 'password mismatch', |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | - public function checkPass($password,$database_pass) |
|
| 63 | + public function checkPass($password, $database_pass) |
|
| 64 | 64 | { |
| 65 | - if($database_pass == $password){ |
|
| 65 | + if ($database_pass == $password) { |
|
| 66 | 66 | return true; |
| 67 | 67 | } |
| 68 | 68 | return false; |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $setting = Config::get('settings.auth'); |
| 38 | 38 | if($setting['2step']){ |
| 39 | 39 | $this->twoStepAuth(); |
| 40 | - }else{ |
|
| 40 | + } else{ |
|
| 41 | 41 | if ($this->checkPass($password,$user->password)) { |
| 42 | 42 | $_SESSION['user']['user_id'] = $user->id; |
| 43 | 43 | $_SESSION['user']['mobile'] = $user->mobile; |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | 'type'=>'success', |
| 46 | 46 | 'message'=> 'Logined', |
| 47 | 47 | ]; |
| 48 | - }else{ |
|
| 48 | + } else{ |
|
| 49 | 49 | return [ |
| 50 | 50 | 'type'=>'error', |
| 51 | 51 | 'message'=> 'password mismatch', |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | { |
| 13 | 13 | Capsule::schema()->table('users', function($table) |
| 14 | 14 | { |
| 15 | - $table->string('password',128); |
|
| 15 | + $table->string('password', 128); |
|
| 16 | 16 | }); |
| 17 | 17 | } |
| 18 | 18 | |