|
|
@ -16,9 +16,7 @@ class SecurityController
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
$success = $di->getSecurity()->initLogin($_POST['login'], $_POST['password']);
|
|
|
|
$success = $di->getSecurity()->initLogin($_POST['login'], $_POST['password']);
|
|
|
|
if ($success) {
|
|
|
|
if ($success) {
|
|
|
|
http_response_code(303);
|
|
|
|
HttpResponse::redirect($di->getRouter()->url(''));
|
|
|
|
header('Location: ' . $di->getRouter()->url(''));
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fail = !$success;
|
|
|
|
$fail = !$success;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -31,12 +29,16 @@ class SecurityController
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
$user = $di->getSecurity()->register(User::fromRawPassword($_POST['login'], $_POST['password']));
|
|
|
|
$user = $di->getSecurity()->register(User::fromRawPassword($_POST['login'], $_POST['password']));
|
|
|
|
if ($user !== null) {
|
|
|
|
if ($user !== null) {
|
|
|
|
http_response_code(303);
|
|
|
|
HttpResponse::redirect($di->getRouter()->url(''));
|
|
|
|
header('Location: ' . $di->getRouter()->url(''));
|
|
|
|
|
|
|
|
exit();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$fail = $user === null;
|
|
|
|
$fail = $user === null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return HttpResponse::found('register', ['fail' => $fail]);
|
|
|
|
return HttpResponse::found('register', ['fail' => $fail]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function logout(DI $di): void
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$di->getSecurity()->logout();
|
|
|
|
|
|
|
|
HttpResponse::redirect($di->getRouter()->url(''));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|