Simplification
This commit is contained in:
@@ -6,7 +6,7 @@ class AuthController extends Controller
|
||||
{
|
||||
public function show(): void
|
||||
{
|
||||
if ($this->user()) {
|
||||
if ($this->currentUser()) {
|
||||
$this->f3->reroute('@dashboard');
|
||||
return;
|
||||
}
|
||||
@@ -16,10 +16,11 @@ class AuthController extends Controller
|
||||
|
||||
public function login(): void
|
||||
{
|
||||
$this->checkCsrf();
|
||||
$this->verifyCsrf();
|
||||
|
||||
$user = new User();
|
||||
$auth = new Auth($user, ['id' => 'username', 'pw' => 'password_hash'], 'password_verify');
|
||||
|
||||
$ok = $auth->login(
|
||||
$this->f3->clean((string) ($this->f3->get('POST.username') ?: '')),
|
||||
(string) ($this->f3->get('POST.password') ?: '')
|
||||
@@ -27,7 +28,7 @@ class AuthController extends Controller
|
||||
|
||||
if (!$ok) {
|
||||
usleep(1000000);
|
||||
$this->flash('error', 'Identifiants invalides.');
|
||||
$this->flash('error', 'Identifiants incorrects.');
|
||||
$this->f3->reroute('@login');
|
||||
return;
|
||||
}
|
||||
@@ -41,11 +42,11 @@ class AuthController extends Controller
|
||||
|
||||
public function logout(): void
|
||||
{
|
||||
$this->checkCsrf();
|
||||
$this->verifyCsrf();
|
||||
$this->f3->clear('SESSION.user_id');
|
||||
session_regenerate_id(true);
|
||||
$this->rotateCsrf();
|
||||
$this->flash('success', 'Déconnexion effectuée.');
|
||||
$this->flash('success', 'Déconnexion réussie.');
|
||||
$this->f3->reroute('@login');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user