From 0b2c5279a8cf828d3a78cb863a09000e8f35d578 Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Thu, 16 Feb 2017 20:40:21 +0100 Subject: [PATCH 1/3] allow to use the username for login as well add translation strings --- app/Http/Controllers/Auth/LoginController.php | 9 ++++++--- resources/lang/en/strings.php | 1 + resources/themes/pterodactyl/auth/login.blade.php | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 4ce580445..42f40fb00 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 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) { diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index d1862f0ba..60be75e2d 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -2,6 +2,7 @@ return [ 'email' => 'Email', + 'user_identifier' => 'Email or password', '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')

- +
From 4fc832838b0b06920964c2885749f977e4d508ee Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Thu, 16 Feb 2017 20:45:36 +0100 Subject: [PATCH 2/3] =?UTF-8?q?use=20=E2=80=9Arequired|string=E2=80=98=20t?= =?UTF-8?q?o=20validate=20usernames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Auth/LoginController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index 42f40fb00..d4d8c89c3 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -87,11 +87,11 @@ class LoginController extends Controller */ public function login(Request $request) { - // Check wether login is an email address or a username + // Check wether the user identifier is an email address or a username $isEmail = str_contains($request->input('user'), '@'); $this->validate($request, [ - 'user' => $isEmail ? 'required|email' : 'required', + 'user' => $isEmail ? 'required|email' : 'required|string', 'password' => 'required', ]); From bdf8b473d472e1d15d2d2492a8437989339489dd Mon Sep 17 00:00:00 2001 From: Jakob Schrettenbrunner Date: Thu, 16 Feb 2017 20:46:37 +0100 Subject: [PATCH 3/3] fix translations for login field --- resources/lang/en/strings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/lang/en/strings.php b/resources/lang/en/strings.php index 60be75e2d..4107da35f 100644 --- a/resources/lang/en/strings.php +++ b/resources/lang/en/strings.php @@ -2,7 +2,7 @@ return [ 'email' => 'Email', - 'user_identifier' => 'Email or password', + 'user_identifier' => 'Username or Email', 'password' => 'Password', 'confirm_password' => 'Confirm Password', 'login' => 'Login',