@@ -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 | - session(["login_verification_code"=>$code,"last_id_attempt"=>auth()->id()]); |
|
44 | + session(["login_verification_code"=>$code, "last_id_attempt"=>auth()->id()]); |
|
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 && session("last_id_attempt")) { |
|
92 | + if (request("code") == $sessCode && session("last_id_attempt")) { |
|
93 | 93 | // Login |
94 | 94 | auth()->loginUsingId(session("last_id_attempt")); |
95 | 95 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $this->clearSuspendAttempt(); |
105 | 105 | |
106 | 106 | // Clear verification session |
107 | - session()->forget(["last_id_attempt","login_verification_code"]); |
|
107 | + session()->forget(["last_id_attempt", "login_verification_code"]); |
|
108 | 108 | |
109 | 109 | cbHook()->hookPostLogin(); |
110 | 110 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | - return cb()->redirectBack("The code is invalid!","warning"); |
|
115 | + return cb()->redirectBack("The code is invalid!", "warning"); |
|
116 | 116 | |
117 | 117 | } catch (CBValidationException $e) { |
118 | 118 | return cb()->redirectBack($e->getMessage()); |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | |
122 | 122 | public function postLogin() |
123 | 123 | { |
124 | - try{ |
|
125 | - if($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
124 | + try { |
|
125 | + if ($this->isSuspendedLogin()) throw new CBValidationException(cbLang("you_have_been_suspended")); |
|
126 | 126 | |
127 | 127 | cb()->validation([ |
128 | 128 | 'email'=>'required|email', |
129 | 129 | 'password'=>'required' |
130 | 130 | ]); |
131 | 131 | |
132 | - $credential = request()->only(['email','password']); |
|
132 | + $credential = request()->only(['email', 'password']); |
|
133 | 133 | if (auth()->attempt($credential)) { |
134 | 134 | |
135 | 135 | // Check if login notification is enabled |
136 | - if($this->loginNotification()) { |
|
137 | - return cb()->redirect(route("AdminAuthControllerGetLoginVerification"),"We have sent you a code verification, please enter to this box"); |
|
136 | + if ($this->loginNotification()) { |
|
137 | + return cb()->redirect(route("AdminAuthControllerGetLoginVerification"), "We have sent you a code verification, please enter to this box"); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | // Update Login At |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | return redirect(cb()->getAdminUrl()); |
153 | 153 | } else { |
154 | 154 | $this->incrementFailedLogin(); |
155 | - return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'),'message_type'=>'warning']); |
|
155 | + return redirect(cb()->getLoginUrl())->with(['message'=>cbLang('password_and_username_is_wrong'), 'message_type'=>'warning']); |
|
156 | 156 | } |
157 | - }catch (CBValidationException $e) { |
|
158 | - return cb()->redirect(cb()->getAdminUrl("login"),$e->getMessage(),'warning'); |
|
157 | + } catch (CBValidationException $e) { |
|
158 | + return cb()->redirect(cb()->getAdminUrl("login"), $e->getMessage(), 'warning'); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 |