@@ -20,31 +20,31 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public function getLogin() |
| 22 | 22 | { |
| 23 | - if(!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 23 | + if (!auth()->guest()) return redirect(cb()->getAdminUrl()); |
|
| 24 | 24 | |
| 25 | 25 | cbHook()->hookGetLogin(); |
| 26 | 26 | |
| 27 | 27 | $data = []; |
| 28 | - $data['no1'] = rand(1,10); |
|
| 29 | - $data['no2'] = rand(1,10); |
|
| 30 | - Session::put("captcha_result", $data['no1']+$data['no2']); |
|
| 28 | + $data['no1'] = rand(1, 10); |
|
| 29 | + $data['no2'] = rand(1, 10); |
|
| 30 | + Session::put("captcha_result", $data['no1'] + $data['no2']); |
|
| 31 | 31 | |
| 32 | 32 | $themeView = getThemePath("login"); |
| 33 | - $loginView = str_replace(".blade.php", "", getSetting('login_page_view',$themeView)); |
|
| 34 | - return view($loginView, $data ); |
|
| 33 | + $loginView = str_replace(".blade.php", "", getSetting('login_page_view', $themeView)); |
|
| 34 | + return view($loginView, $data); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | private function loginNotification() { |
| 38 | - if($isLoginNotification = getSetting("LOGIN_NOTIFICATION")) { |
|
| 38 | + if ($isLoginNotification = getSetting("LOGIN_NOTIFICATION")) { |
|
| 39 | 39 | $user = auth()->user(); |
| 40 | - if($user->ip_address && $user->user_agent) { |
|
| 40 | + if ($user->ip_address && $user->user_agent) { |
|
| 41 | 41 | |
| 42 | - if( request()->ip() != $user->ip_address || request()->userAgent() != $user->user_agent) { |
|
| 42 | + if (request()->ip() != $user->ip_address || request()->userAgent() != $user->user_agent) { |
|
| 43 | 43 | $code = Str::random(5); |
| 44 | 44 | session(["login_verification_code"=>$code]); |
| 45 | 45 | $mail = new MailHelper(); |
| 46 | 46 | $mail->to($user->email); |
| 47 | - $mail->sender("noreply@".$_SERVER['SERVER_NAME'],cb()->getAppName()); |
|
| 47 | + $mail->sender("noreply@".$_SERVER['SERVER_NAME'], cb()->getAppName()); |
|
| 48 | 48 | $mail->subject("Please verify that it's you?"); |
| 49 | 49 | $mail->content(" |
| 50 | 50 | Hi $user->name,<br/><br> |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | try { |
| 88 | 88 | cb()->validation(["code"]); |
| 89 | 89 | |
| 90 | - if(session()->has("login_verification_code")) { |
|
| 90 | + if (session()->has("login_verification_code")) { |
|
| 91 | 91 | $sessCode = session("login_verification_code"); |
| 92 | - if(request("code") == $sessCode) { |
|
| 92 | + if (request("code") == $sessCode) { |
|
| 93 | 93 | // Update Login At |
| 94 | 94 | cb()->update("users", auth()->id(), [ |
| 95 | 95 | "login_at"=>now()->format("Y-m-d H:i:s"), |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - return cb()->redirectBack("The code is invalid!","warning"); |
|
| 109 | + return cb()->redirectBack("The code is invalid!", "warning"); |
|
| 110 | 110 | |
| 111 | 111 | } catch (CBValidationException $e) { |
| 112 | 112 | return cb()->redirectBack($e->getMessage()); |
@@ -115,20 +115,20 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function postLogin() |
| 117 | 117 | { |
| 118 | - try{ |
|
| 119 | - if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
| 118 | + try { |
|
| 119 | + if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
| 120 | 120 | |
| 121 | 121 | cb()->validation([ |
| 122 | 122 | 'email'=>'required|email', |
| 123 | 123 | 'password'=>'required' |
| 124 | 124 | ]); |
| 125 | 125 | |
| 126 | - $credential = request()->only(['email','password']); |
|
| 126 | + $credential = request()->only(['email', 'password']); |
|
| 127 | 127 | if (auth()->attempt($credential)) { |
| 128 | 128 | |
| 129 | 129 | // Check if login notification is enabled |
| 130 | - if($this->loginNotification()) { |
|
| 131 | - return cb()->redirect(route("AdminAuthControllerGetLoginVerification"),"We have sent you a code verification, please enter to this box"); |
|
| 130 | + if ($this->loginNotification()) { |
|
| 131 | + return cb()->redirect(route("AdminAuthControllerGetLoginVerification"), "We have sent you a code verification, please enter to this box"); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // Update Login At |
@@ -146,10 +146,10 @@ discard block |
||
| 146 | 146 | return redirect(cb()->getAdminUrl()); |
| 147 | 147 | } else { |
| 148 | 148 | $this->incrementFailedLogin(); |
| 149 | - return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
|
| 149 | + return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']); |
|
| 150 | 150 | } |
| 151 | - }catch (CBValidationException $e) { |
|
| 152 | - return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
|
| 151 | + } catch (CBValidationException $e) { |
|
| 152 | + return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning'); |
|
| 153 | 153 | } |
| 154 | 154 | } |
| 155 | 155 | |