Allow resetting password through email.

This also adopts the use of an Alert template for error and success messages.
This commit is contained in:
2016-09-02 11:17:10 +02:00
parent 3587447cc0
commit 7487068171
13 changed files with 456 additions and 20 deletions

View File

@@ -29,9 +29,12 @@ class Login extends HTMLController
if (isset($_POST['redirect_url']))
header('Location: ' . base64_decode($_POST['redirect_url']));
elseif (isset($_SESSION['login_url']))
{
unset($_SESSION['redirect_url']);
header('Location: ' . $_SESSION['redirect_url']);
}
else
header('Location: ' . BASEURL . '/admin/');
header('Location: ' . BASEURL . '/');
exit;
}
else
@@ -39,15 +42,28 @@ class Login extends HTMLController
}
parent::__construct('Log in - ' . SITE_TITLE);
$this->page->appendStylesheet(BASEURL . '/css/admin.css');
$form = new LogInForm('Log in');
if ($login_error)
$form->setErrorMessage('Invalid email address or password.');
$form->adopt(new Alert('', 'Invalid email address or password.', 'error'));
// Tried anything? Be helpful, at least.
if (isset($_POST['emailaddress']))
$form->setEmail($_POST['emailaddress']);
// A message from the past/present/future?
if (isset($_SESSION['login_msg']))
{
$form->adopt(new Alert($_SESSION['login_msg'][0], $_SESSION['login_msg'][1], $_SESSION['login_msg'][2]));
unset($_SESSION['login_msg']);
}
// Going somewhere?
if (!empty($_GET['redirect']) && ($url = base64_decode($_GET['redirect'])))
{
$_SESSION['login_url'] = $url;
$form->setRedirectUrl($url);
}
$this->page->adopt($form);
}
}