Skip to content

Commit

Permalink
Fix user login by email
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 22, 2018
1 parent 656f0d6 commit b7fef38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
2018-09-22 DariusIIi
* Fix: Fix user login by email
2018-09-21 DariusIII
* Chg: Update install script to set admin as verified
* Chg: Update nesbot/carbon to version 1.34.0 and fancybox to latest
Expand Down
14 changes: 8 additions & 6 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,15 @@ public function login(Request $request)
]);

$error = '';
$login_type = filter_var($request->input('username'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';

$request->merge([
$login_type => $request->input('username'),
]);
$user = User::getByUsername($request->input('username'));
if ($user === null) {
$user = User::getByEmail($request->input('username'));
}

if ($user !== null && \Firewall::isBlacklisted($user->host) === false) {
if (env('NOCAPTCHA_ENABLED') === true && (! empty(env('NOCAPTCHA_SECRET')) && ! empty(env('NOCAPTCHA_SITEKEY')))) {
Expand All @@ -64,12 +72,6 @@ public function login(Request $request)

$rememberMe = $request->has('rememberme') && $request->input('rememberme') === 'on';

$login_type = filter_var($request->input('username'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username';

$request->merge([
$login_type => $request->input('username'),
]);

if ($user->isVerified() === false || $user->isPendingVerification()) {
return $this->showLoginForm('You have not verified your email address!');
}
Expand Down

0 comments on commit b7fef38

Please sign in to comment.