Add password reset message
This commit is contained in:
parent
062232a71d
commit
b176ed1dc6
4 changed files with 14 additions and 13 deletions
|
@ -91,6 +91,7 @@ class Page
|
|||
* Non-Static
|
||||
*/
|
||||
public string $language = 'en';
|
||||
public array $messages = array();
|
||||
|
||||
/**
|
||||
* __construct
|
||||
|
@ -482,11 +483,11 @@ class Page
|
|||
<?php
|
||||
}
|
||||
|
||||
public function messages(array $messages): string
|
||||
public function messages(): string
|
||||
{
|
||||
$html = '';
|
||||
|
||||
foreach ($messages as $message) {
|
||||
foreach ($this->messages as $message) {
|
||||
$html .= $message;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,8 @@ if (isset($_POST['reset'], $_POST['email'])) {
|
|||
|
||||
$emailReset = new Email($_POST['email'], 'Password reset link', $mjml);
|
||||
$emailReset->send();
|
||||
|
||||
$page->messages[] = Page::info('If we can find a match for this email address, a password reset link will be sent to it.', 'Info');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@
|
|||
|
||||
use wishthis\Page;
|
||||
|
||||
$page = new page(__FILE__, 'Register');
|
||||
$messages = array();
|
||||
$page = new page(__FILE__, 'Register');
|
||||
|
||||
if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
||||
$users = $database->query('SELECT * FROM `users`;')->fetchAll();
|
||||
|
@ -43,7 +42,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
|||
}
|
||||
|
||||
if (in_array($planet, $not_planets)) {
|
||||
$messages[] = Page::warning('<strong>' . $planetName . '</strong> is not a planet but I\'ll let it slide, since only a human would make this kind of mistake.', 'Invalid planet');
|
||||
$page->messages[] = Page::warning('<strong>' . $planetName . '</strong> is not a planet but I\'ll let it slide, since only a human would make this kind of mistake.', 'Invalid planet');
|
||||
}
|
||||
|
||||
if ($isHuman) {
|
||||
|
@ -61,7 +60,7 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
|||
;');
|
||||
} else {
|
||||
if (in_array($_POST['email'], $emails)) {
|
||||
$messages[] = Page::error('An account with this email address already exists.', 'Invalid email address');
|
||||
$page->messages[] = Page::error('An account with this email address already exists.', 'Invalid email address');
|
||||
} else {
|
||||
$database->query('INSERT INTO `users`
|
||||
(
|
||||
|
@ -73,11 +72,11 @@ if (isset($_POST['email'], $_POST['password']) && !empty($_POST['planet'])) {
|
|||
)
|
||||
;');
|
||||
|
||||
$messages[] = Page::success('Your account was successfully created.', 'Success');
|
||||
$page->messages[] = Page::success('Your account was successfully created.', 'Success');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$messages[] = Page::error('<strong>' . $planetName . '</strong> is not a planet in our solar system. Read this for more information: <a href="https://www.space.com/16080-solar-system-planets.html" target="_blank">Solar system planets: Order of the 8 (or 9) planets</a>', 'Invalid planet');
|
||||
$page->messages[] = Page::error('<strong>' . $planetName . '</strong> is not a planet in our solar system. Read this for more information: <a href="https://www.space.com/16080-solar-system-planets.html" target="_blank">Solar system planets: Order of the 8 (or 9) planets</a>', 'Invalid planet');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,7 +88,7 @@ $page->navigation();
|
|||
<div class="ui container">
|
||||
<h1 class="ui header"><?= $page->title ?></h1>
|
||||
|
||||
<?= $page->messages($messages) ?>
|
||||
<?= $page->messages() ?>
|
||||
|
||||
<div class="ui segment">
|
||||
<form class="ui form" method="post">
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
use wishthis\{Page, Wish};
|
||||
|
||||
$messages = array();
|
||||
$page = new page(__FILE__, $wish->title);
|
||||
|
||||
if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) {
|
||||
$database
|
||||
|
@ -18,7 +18,7 @@ if ('POST' === $_SERVER['REQUEST_METHOD'] && count($_POST) >= 0) {
|
|||
`url` = "' . trim($_POST['wish_url']) . '"
|
||||
WHERE `id` = ' . trim($_POST['wish_id']) . ';');
|
||||
|
||||
$messages[] = Page::success('Wish successfully updated.', 'Success');
|
||||
$page->messages[] = Page::success('Wish successfully updated.', 'Success');
|
||||
}
|
||||
|
||||
$userIsAuthenticated = false;
|
||||
|
@ -41,7 +41,6 @@ if (!$userIsAuthenticated) {
|
|||
die();
|
||||
}
|
||||
|
||||
$page = new page(__FILE__, $wish->title);
|
||||
$page->header();
|
||||
$page->bodyStart();
|
||||
$page->navigation();
|
||||
|
@ -53,7 +52,7 @@ $referer = '/?page=wishlists&wishlist=' . $wish->wishlist;
|
|||
<div class="ui container">
|
||||
<h1 class="ui header"><?= $page->title ?></h1>
|
||||
|
||||
<?= $page->messages($messages) ?>
|
||||
<?= $page->messages() ?>
|
||||
|
||||
<div class="ui segment">
|
||||
<form class="ui form wish" method="POST">
|
||||
|
|
Loading…
Reference in a new issue