1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-12-22 13:45:02 +00:00

Make email address verification email sending more intelligent and update changelog

This commit is contained in:
Starbeamrainbowlabs 2020-01-05 21:16:51 +00:00
parent 3c47bf0539
commit 344b7daa70
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 11 additions and 5 deletions

View file

@ -6,6 +6,9 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
## Added
- Watchlists! A new addition has been added to the more menu to add the current page to your personal watchlist
- An email will be sent to all users watching a page when an edit is saved to it (uses the PHP `mail()` function internally, via the [`email_user()`](https://starbeamrainbowlabs.com/labs/peppermint/docs/ModuleApi/#method_email_user) internal Pepperminty Wiki utility function)
- Email address verification
- Enabled by default. In order to receive emails users now need to verify their email address
- This is done via a verification email that's sent when you change your email address (even if your email address is the same when you change your preferences and you haven't yet verified it)
## Fixed
- Fixed weighted word support on search query analysis debug page

View file

@ -67,7 +67,7 @@ register_module([
$content .= " <input type='email' id='email-address' name='email-address' placeholder='e.g. bob@bobsrockets.com' value='{$env->user_data->emailAddress}' />\n";
$content .= " <p><small>Used to send you notifications etc. Never shared with anyone except $settings->admindetails_name, $settings->sitename's administrator.</small></p>\n";
if($settings->email_user_verify) {
$content .= " <p>Email verification status: <strong>".(empty($env->user_data->emailAddressVerified) ? "not " : "")."verified</strong> <small><em>(Email address verification is required in order to receive emails (other than the verification email itself, of course). Click the link in the verification email sent to you to verify your address, or change it here to get another verification email)</em></small></p>";
$content .= " <p>Email verification status: <strong>".(empty($env->user_data->emailAddressVerified) ? "not " : "")."verified</strong> <small><em>(Email address verification is required in order to receive emails (other than the verification email itself, of course). Click the link in the verification email sent to you to verify your address, or change it here to get another verification email - changing it to the same email address is ok)</em></small></p>";
}
$content .= " <input type='submit' value='Save Preferences' />\n";
$content .= "</form>\n";
@ -118,11 +118,14 @@ register_module([
}
$old_address = $env->user_data->emailAddress ?? null;
$env->user_data->emailAddress = $_POST["email-address"];
// If email address verification is required and the email
// address has changed, send a verification email now
if($settings->email_user_verify && $old_address !== $_POST["email-address"]) {
$env->user_data->emailAddressVerified = false;
if(!email_user_verify($env->user)) {
if($settings->email_user_verify) {
if(empty($env->user_data->emailAddressVerified) && $old_address !== $_POST["email-address"])
$env->user_data->emailAddressVerified = false;
if(empty($env->user_data->emailAddressVerified) && !email_user_verify($env->user)) {
http_response_code(503);
exit(page_renderer::render_main("Server error sending verification code - $settings->sitename", "<p>$settings->sitename tried to send you an email to verify your email address, but was unable to do so. The changes to your settings have not been saved. Please contact $settings->admindetails_name, whose email address can be found at the bottom of this page.</p>"));
}
@ -175,7 +178,7 @@ register_module([
http_resonse_code(400);
header("x-status: failed");
header("x-problem: code-incorrect");
exit(page_renderer::render_main("Verification code incorrect", "<p>That verification code was incorrect. Try specifying another one, or going to your <a href='?action=user-preferences'>user preferences</a> and changing your email address to re-send another code.</p>"));
exit(page_renderer::render_main("Verification code incorrect", "<p>That verification code was incorrect. Try specifying another one, or going to your <a href='?action=user-preferences'>user preferences</a> and changing your email address to re-send another code (changing it to the same email address is ok).</p>"));
}
// The code supplied must be valid