@@ -50,10 +50,7 @@ public function __construct()
5050 */
5151 public function loginView ()
5252 {
53- // Check if magic-link is not allowed
54- if (! setting ('Auth.allowMagicLinkLogins ' )) {
55- return redirect ()->route ('login ' )->with ('error ' , lang ('Auth.magicLinkDisabled ' ));
56- }
53+ $ this ->displayErrorMagicLinkDisabled ();
5754
5855 if (auth ()->loggedIn ()) {
5956 return redirect ()->to (config ('Auth ' )->loginRedirect ());
@@ -71,10 +68,7 @@ public function loginView()
7168 */
7269 public function loginAction ()
7370 {
74- // Check if magic-link is not allowed
75- if (! setting ('Auth.allowMagicLinkLogins ' )) {
76- return redirect ()->route ('login ' )->with ('error ' , lang ('Auth.magicLinkDisabled ' ));
77- }
71+ $ this ->displayErrorMagicLinkDisabled ();
7872
7973 // Validate email format
8074 $ rules = $ this ->getValidationRules ();
@@ -145,10 +139,7 @@ protected function displayMessage(): string
145139 */
146140 public function verify (): RedirectResponse
147141 {
148- // Check if magic-link is not allowed
149- if (! setting ('Auth.allowMagicLinkLogins ' )) {
150- return redirect ()->route ('login ' )->with ('error ' , lang ('Auth.magicLinkDisabled ' ));
151- }
142+ $ this ->displayErrorMagicLinkDisabled ();
152143
153144 $ token = $ this ->request ->getGet ('token ' );
154145
@@ -228,6 +219,18 @@ private function recordLoginAttempt(
228219 );
229220 }
230221
222+ /**
223+ * Display error to the user if magic-link is not allowed.
224+ *
225+ * @return RedirectResponse|void
226+ */
227+ private function displayErrorMagicLinkDisabled ()
228+ {
229+ if (! setting ('Auth.allowMagicLinkLogins ' )) {
230+ return redirect ()->route ('login ' )->with ('error ' , lang ('Auth.magicLinkDisabled ' ));
231+ }
232+ }
233+
231234 /**
232235 * Returns the rules that should be used for validation.
233236 *
0 commit comments