1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-22 04:23:01 +00:00

Bugfix: Consolidate user->email & user->emailAddress.

Also add an auto-migrator on login.

Fixes #167
This commit is contained in:
Starbeamrainbowlabs 2019-05-06 23:44:38 +01:00
parent f3d797695e
commit 4e801c4692
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 12 additions and 4 deletions

View file

@ -8,7 +8,8 @@ This file holds the changelog for Pepperminty Wiki. This is the master list of t
### Fixed ### Fixed
- Fixed double-escaping of rendered HTML when nesting templates - Fixed double-escaping of rendered HTML when nesting templates
- Squashed a warning if the search index doesn't exist yet - Squashed a warning if the search index doesn't exist yet
- Fixed the stats updater if no pages in the system have tags yet - Fixed a crash in the stats updater if no pages in the system have tags yet
- Consolidated `email` and `emailAddress` fields into the latter in the user table (#167)
### Added ### Added
- [Module API] Added new extra data system. See `parser-parsedown` and `page-edit` for an example. - [Module API] Added new extra data system. See `parser-parsedown` and `page-edit` for an example.

View file

@ -44,8 +44,8 @@ register_module([
foreach($settings->users as $username => $user_data) { foreach($settings->users as $username => $user_data) {
$content .= "<tr>"; $content .= "<tr>";
$content .= "<td>" . page_renderer::render_username($username) . "</td>"; $content .= "<td>" . page_renderer::render_username($username) . "</td>";
if(!empty($user_data->email)) if(!empty($user_data->emailAddress))
$content .= "<td><a href='mailto:" . htmlentities($user_data->email, ENT_HTML5 | ENT_QUOTES) . "'>" . htmlentities($user_data->email) . "</a></td>\n"; $content .= "<td><a href='mailto:" . htmlentities($user_data->emailAddress, ENT_HTML5 | ENT_QUOTES) . "'>" . htmlentities($user_data->emailAddress) . "</a></td>\n";
else else
$content .= "<td><em>(None provided)</em></td>\n"; $content .= "<td><em>(None provided)</em></td>\n";
$content .= "<td>"; $content .= "<td>";
@ -119,7 +119,7 @@ register_module([
$user_data = new stdClass(); $user_data = new stdClass();
$user_data->password = hash_password($new_password); $user_data->password = hash_password($new_password);
if(!empty($new_email)) if(!empty($new_email))
$user_data->email = $new_email; $user_data->emailAddress = $new_email;
$settings->users->$new_username = $user_data; $settings->users->$new_username = $user_data;

View file

@ -114,6 +114,13 @@ register_module([
error_log("[Pepperminty Wiki] Updated password hash for $user."); error_log("[Pepperminty Wiki] Updated password hash for $user.");
} }
// If the email address is still in the old field, migrate it
if(!empty($settings->users->{$user}->email)) {
$settings->users->{$user}->emailAddress = $settings->users->{$user}->email;
unset($settings->users->{$user}->email);
save_settings();
}
$_SESSION["$settings->sessionprefix-user"] = $user; $_SESSION["$settings->sessionprefix-user"] = $user;
$_SESSION["$settings->sessionprefix-pass"] = $new_password_hash ?? hash_password($pass); $_SESSION["$settings->sessionprefix-pass"] = $new_password_hash ?? hash_password($pass);
$_SESSION["$settings->sessionprefix-expiretime"] = time() + 60*60*24*30; // 30 days from now $_SESSION["$settings->sessionprefix-expiretime"] = time() + 60*60*24*30; // 30 days from now