container->getConfig()['defaultLoginRedirectPage'];
if(array_key_exists('lastPage', $_SESSION)) {
$this->redirect($_SESSION('lastPage'));
} else {
$this->redirect($defaultPage);
}
}
public function loginAction() {
$login = $this->container->getLogin();
if($login->isLoggedIn()) {
$this->doRedirect();
}
$errors = array();
if($_SERVER['REQUEST_METHOD'] === 'POST') {
$username = $this->getPostVariable("username");
$password = $this->getPostVariable("password");
if(empty($username)) {
$errors['username'] = "Please enter a Username.";
}
if(empty($password)) {
$errors['password'] = "Please enter a Password.";
}
if(!empty($username) && !empty($password)) {
if($login->login($username, $password)) {
$this->container->setNotice("Success! You have been successfully logged in.");
$this->doRedirect();
} else {
$errors['login'] = "Invalid credentials. Please check your username and password, and try again.";
}
}
}
$values = array();
$values['errors'] = $errors;
$this->container->setTitle("Login");
$this->container->render("login.html.php", $values);
}
public function logoutAction() {
$login = $this->container->getLogin();
$login->logout();
// force a new session, for the notice
$this->container->login = new Login($this->container->storage);
$this->container->setNotice("Success! You have been successfully logged out.");
$this->redirect($this->container->getConfig()['defaultLoginRedirectPage']);
}
}