| Conditions | 4 |
| Paths | 4 |
| Total Lines | 30 |
| Code Lines | 22 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | public function attempt(string $loginField,string $password) |
||
| 45 | { |
||
| 46 | $user = UserDataAccess::getUserLoginField($loginField); |
||
| 47 | if (!$user) { |
||
| 48 | return [ |
||
| 49 | 'type'=>'error', |
||
| 50 | 'message'=> 'User Not Exists', |
||
| 51 | ]; |
||
| 52 | } |
||
| 53 | $setting = Config::get('settings.auth'); |
||
| 54 | if($setting['2step']){ |
||
| 55 | $this->twoStepAuth(); |
||
| 56 | }else{ |
||
| 57 | if ($this->checkPass($password,$user->password)) { |
||
| 58 | $_SESSION['user']['user_id'] = $user->id; |
||
| 59 | $_SESSION['user']['mobile'] = $user->mobile; |
||
| 60 | return [ |
||
| 61 | 'type'=>'success', |
||
| 62 | 'message'=> 'Logined', |
||
| 63 | ]; |
||
| 64 | }else{ |
||
| 65 | return [ |
||
| 66 | 'type'=>'error', |
||
| 67 | 'message'=> 'password mismatch', |
||
| 68 | ]; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | return [ |
||
| 72 | 'type'=>'error', |
||
| 73 | 'message'=> 'problem!', |
||
| 74 | ]; |
||
| 100 | } |