Skip to content

Commit

Permalink
Fix display of login errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DariusIII committed Sep 7, 2018
1 parent 87610f5 commit 03267cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
2018-09-07 DariusIII
* Fix: Display login errors
* Chg: Update ytake/laravel-smarty to version 2.4.0
2018-09-06 DariusIII
* Chg: Update spatie/laravel-permission and barryvdh/laravel-ide-helper to latest versions
Expand Down
15 changes: 11 additions & 4 deletions app/Http/Controllers/Auth/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\User;
use App\Models\Settings;
use Blacklight\ColorCLI;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
Expand Down Expand Up @@ -52,6 +53,7 @@ public function login(Request $request)
'password' => 'required',
]);

$error = '';
$user = User::getByUsername($request->input('username'));

if ($user !== null && \Firewall::isBlacklisted($user->host) === false) {
Expand All @@ -74,18 +76,23 @@ public function login(Request $request)

return redirect()->intended($this->redirectPath());
}

$error = 'Username/email and password combination used does not match our records!';
} else {
$error = 'Username or email used do not match our records!';
}

return redirect()->back();
return $this->showLoginForm($error);
}

/**
* @throws \Exception
* @param string $error
* @param string $notice
*/
public function showLoginForm()
public function showLoginForm($error = '', $notice = '')
{
$theme = Settings::settingValue('site.main.style');
app('smarty.view')->assign(['error' => '', 'username' => '', 'rememberme' => '']);
app('smarty.view')->assign(['error' => $error, 'notice' => $notice, 'username' => '', 'rememberme' => '']);

$meta_title = 'Login';
$meta_keywords = 'Login';
Expand Down

0 comments on commit 03267cf

Please sign in to comment.