allow to use the username for login as well
add translation strings
This commit is contained in:
parent
2e134b7a55
commit
0b2c5279a8
3 changed files with 8 additions and 4 deletions
|
@ -87,8 +87,11 @@ class LoginController extends Controller
|
|||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
// Check wether login is an email address or a username
|
||||
$isEmail = str_contains($request->input('user'), '@');
|
||||
|
||||
$this->validate($request, [
|
||||
'email' => 'required|email',
|
||||
'user' => $isEmail ? 'required|email' : 'required',
|
||||
'password' => 'required',
|
||||
]);
|
||||
|
||||
|
@ -98,9 +101,9 @@ class LoginController extends Controller
|
|||
return $this->sendLockoutResponse($request);
|
||||
}
|
||||
|
||||
// Is the email & password valid?
|
||||
// Is the user (email or username) & password valid?
|
||||
if (! Auth::once([
|
||||
'email' => $request->input('email'),
|
||||
$isEmail ? 'email' : 'username' => $request->input('user'),
|
||||
'password' => $request->input('password'),
|
||||
], $request->has('remember'))) {
|
||||
if (! $lockedOut) {
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
return [
|
||||
'email' => 'Email',
|
||||
'user_identifier' => 'Email or password',
|
||||
'password' => 'Password',
|
||||
'confirm_password' => 'Confirm Password',
|
||||
'login' => 'Login',
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
<p class="login-box-msg">@lang('auth.authentication_required')</p>
|
||||
<form action="{{ route('auth.login') }}" method="POST">
|
||||
<div class="form-group has-feedback">
|
||||
<input type="email" name="email" class="form-control" value="{{ old('email') }}" placeholder="@lang('strings.email')">
|
||||
<input name="user" class="form-control" value="{{ old('user') }}" placeholder="@lang('strings.user_identifier')">
|
||||
<span class="fa fa-envelope form-control-feedback"></span>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
|
|
Loading…
Reference in a new issue