Replace login and password reset templates

This commit is contained in:
2023-03-11 13:44:36 +01:00
parent 307d34430a
commit 2d1a299fe0
3 changed files with 67 additions and 45 deletions

View File

@@ -11,45 +11,57 @@ class LogInForm extends SubTemplate
private $redirect_url = '';
private $emailaddress = '';
protected $_class = 'content-box container w-50';
public function setRedirectUrl($url)
{
$_SESSION['login_url'] = $url;
$this->redirect_url = $url;
}
public function setEmail($addr)
{
$this->emailaddress = htmlentities($addr);
$this->emailaddress = htmlspecialchars($addr);
}
protected function html_content()
{
echo '
<form action="', BASEURL, '/login/" method="post" id="login">
<h3>Log in</h3>';
if (!empty($this->_title))
echo '
<h1 class="mb-4">Log in to your account</h1>';
foreach ($this->_subtemplates as $template)
$template->html_main();
if (!empty($this->_subtemplates))
{
foreach ($this->_subtemplates as $template)
$template->html_main();
}
echo '
<dl>
<dt><label for="field_emailaddress">E-mail address:</label></dt>
<dd><input type="text" id="field_emailaddress" name="emailaddress" tabindex="1" value="', $this->emailaddress, '" autofocus></dd>
<dt><label for="field_password">Password:</label></dt>
<dd><input type="password" id="field_password" name="password" tabindex="2"></dd>
</dl>';
<form class="mt-4" action="', BASEURL, '/login/" method="post">
<div class="row">
<label class="col-sm-3 col-form-label" for="field_emailaddress">E-mail address:</label>
<div class="col-sm">
<input type="text" class="form-control" id="field_emailaddress" name="emailaddress" value="', $this->emailaddress, '">
</div>
</div>
<div class="row mt-3">
<label class="col-sm-3 col-form-label" for="field_password">Password:</label>
<div class="col-sm">
<input type="password" class="form-control" id="field_password" name="password">
</div>
</div>';
// Throw in a redirect url if asked for.
if (!empty($this->redirect_url))
echo '
<input type="hidden" name="redirect_url" value="', base64_encode($this->redirect_url), '">';
<input type="hidden" name="redirect_url" value="', base64_encode($this->redirect_url), '">';
echo '
<a href="', BASEURL, '/resetpassword/">Forgotten your password?</a>
<div class="buttonstrip">
<button type="submit" class="btn btn-primary" id="field_login" name="login" tabindex="3">Log in</button>
</div>
</form>';
<div class="mt-4">
<div class="offset-sm-3 col-sm-9">
<button type="submit" class="btn btn-primary">Sign in</button>
<a class="btn btn-light" href="', BASEURL, '/resetpassword/" style="margin-left: 1em">Forgotten your password?</a>
</div>
</div>
</form>';
}
}