Merge pull request #299 from Pterodactyl/feature/allow-login-with-username

allow to use the username for login as well
This commit is contained in:
Jakob 2017-02-16 20:47:25 +01:00 committed by GitHub
commit d230ee179a
3 changed files with 8 additions and 4 deletions

View file

@ -87,8 +87,11 @@ class LoginController extends Controller
*/
public function login(Request $request)
{
// Check wether the user identifier is an email address or a username
$isEmail = str_contains($request->input('user'), '@');
$this->validate($request, [
'email' => 'required|email',
'user' => $isEmail ? 'required|email' : 'required|string',
'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) {

View file

@ -2,6 +2,7 @@
return [
'email' => 'Email',
'user_identifier' => 'Username or Email',
'password' => 'Password',
'confirm_password' => 'Confirm Password',
'login' => 'Login',

View file

@ -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">