File tree Expand file tree Collapse file tree 3 files changed +8
-4
lines changed
app/Http/Controllers/Auth Expand file tree Collapse file tree 3 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,11 @@ public function __construct()
8787 */
8888 public function login (Request $ request )
8989 {
90+ // Check wether the user identifier is an email address or a username
91+ $ isEmail = str_contains ($ request ->input ('user ' ), '@ ' );
92+
9093 $ this ->validate ($ request , [
91- 'email ' => 'required|email ' ,
94+ 'user ' => $ isEmail ? 'required|email ' : ' required|string ' ,
9295 'password ' => 'required ' ,
9396 ]);
9497
@@ -98,9 +101,9 @@ public function login(Request $request)
98101 return $ this ->sendLockoutResponse ($ request );
99102 }
100103
101- // Is the email & password valid?
104+ // Is the user ( email or username) & password valid?
102105 if (! Auth::once ([
103- 'email ' => $ request ->input ('email ' ),
106+ $ isEmail ? 'email ' : ' username ' => $ request ->input ('user ' ),
104107 'password ' => $ request ->input ('password ' ),
105108 ], $ request ->has ('remember ' ))) {
106109 if (! $ lockedOut ) {
Original file line number Diff line number Diff line change 22
33return [
44 'email ' => 'Email ' ,
5+ 'user_identifier ' => 'Username or Email ' ,
56 'password ' => 'Password ' ,
67 'confirm_password ' => 'Confirm Password ' ,
78 'login ' => 'Login ' ,
Original file line number Diff line number Diff line change 4747 <p class =" login-box-msg" >@lang (' auth.authentication_required' )</p >
4848 <form action =" {{ route (' auth.login' ) } }" method =" POST" >
4949 <div class =" form-group has-feedback" >
50- <input type = " email " name =" email " class =" form-control" value =" {{ old (' email ' ) } }" placeholder =" @lang (' strings.email ' )" >
50+ <input name =" user " class =" form-control" value =" {{ old (' user ' ) } }" placeholder =" @lang (' strings.user_identifier ' )" >
5151 <span class =" fa fa-envelope form-control-feedback" ></span >
5252 </div >
5353 <div class =" form-group has-feedback" >
You can’t perform that action at this time.
0 commit comments