diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 4ce580445..d4d8c89c3 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -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) { diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index d1862f0ba..4107da35f 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -2,6 +2,7 @@ return [ 'email' => 'Email', + 'user_identifier' => 'Username or Email', 'password' => 'Password', 'confirm_password' => 'Confirm Password', 'login' => 'Login', diff --git a/resources/themes/pterodactyl/auth/login.blade.php b/resources/themes/pterodactyl/auth/login.blade.php index cf18d9b4f..014e848bb 100644 --- a/resources/themes/pterodactyl/auth/login.blade.php +++ b/resources/themes/pterodactyl/auth/login.blade.php @@ -47,7 +47,7 @@
@lang('auth.authentication_required')