Merge remote-tracking branch 'origin/develop' into activitypub

This commit is contained in:
Julian Lam
2024-09-04 14:38:50 -04:00
84 changed files with 299 additions and 196 deletions

View File

@@ -221,20 +221,31 @@ Controllers.registerInterstitial = async function (req, res, next) {
}
};
Controllers.confirmEmail = async (req, res, next) => {
Controllers.confirmEmail = async (req, res) => {
function renderPage(opts = {}) {
res.render('confirm', {
title: '[[pages:confirm]]',
...opts,
});
}
try {
if (req.loggedIn) {
const emailValidated = await user.getUserField(req.uid, 'email:confirmed');
if (emailValidated) {
return renderPage({ alreadyValidated: true });
}
}
await user.email.confirmByCode(req.params.code, req.session.id);
if (req.session.registration) {
// After confirmation, no need to send user back to email change form
delete req.session.registration.updateEmail;
}
res.render('confirm', {
title: '[[pages:confirm]]',
});
renderPage();
} catch (e) {
if (e.message === '[[error:invalid-data]]') {
return next();
if (e.message === '[[error:invalid-data]]' || e.message === '[[error:confirm-email-expired]]') {
renderPage({ error: true });
return;
}
throw e;

View File

@@ -363,7 +363,10 @@ Messaging.canMessageUser = async (uid, toUid) => {
user.blocks.is(uid, toUid),
]);
if (isBlocked || (settings.restrictChat && !isAdmin && !isModerator && !isFollowing)) {
if (isBlocked) {
throw new Error('[[error:chat-user-blocked]]');
}
if (settings.restrictChat && !isAdmin && !isModerator && !isFollowing) {
throw new Error('[[error:chat-restricted]]');
}

View File

@@ -319,6 +319,9 @@ module.exports = function (User) {
if (!correct) {
throw new Error('[[user:change-password-error-wrong-current]]');
}
if (data.currentPassword === data.newPassword) {
throw new Error('[[user:change-password-error-same-password]]');
}
}
const hashedPassword = await User.hashPassword(data.newPassword);

View File

@@ -1,7 +1,19 @@
{{{ if alreadyValidated }}}
<div class="alert alert-info">
<p>[[notifications:email-confirm-error-message-already-validated]]</p>
{{{ end }}}
{{{ if error }}}
<div class="alert alert-warning">
<p>[[notifications:email-confirm-error-message]]</p>
{{{ end }}}
{{{ if (!error && !alreadyValidated )}}}
<div class="alert alert-success">
<strong>[[notifications:email-confirmed]]</strong>
<p>[[notifications:email-confirmed-message]]</p>
<p>
{{{ end }}}
<p class="mb-0">
<a href="{config.relative_path}/">[[notifications:back-to-home, {config.siteTitle}]]</a>
</p>
</div>
</div>

View File

@@ -1,40 +1,42 @@
<div class="row col-12 col-sm-6 offset-sm-3">
{{{ if valid }}}
<div class="card card-body bg-light">
{{{ if displayExpiryNotice }}}
<div class="alert alert-warning">
[[reset_password:password-expired]]
<div class="row">
<div class="col-12 col-sm-6 offset-sm-3">
{{{ if valid }}}
<div class="card card-body bg-light">
{{{ if displayExpiryNotice }}}
<div class="alert alert-warning">
[[reset_password:password-expired]]
</div>
{{{ end }}}
<div class="alert alert-success alert-dismissible hidden" id="success">
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
<strong>[[reset_password:password-changed.title]]</strong>
<p>[[reset_password:password-changed.message]]</p>
</div>
<div class="alert alert-warning hidden" id="notice">
<strong></strong>
<p></p>
</div>
<form onsubmit="return false;" id="reset-form">
<div class="mb-3">
<label class="form-label" for="password">[[reset_password:new-password]]</label>
<input class="form-control" type="password" placeholder="[[reset_password:new-password]]" id="password" />
</div>
<div class="mb-3">
<label class="form-label" for="repeat">[[reset_password:repeat-password]]</label>
<input class="form-control" type="password" placeholder="[[reset_password:repeat-password]]" id="repeat" />
</div>
<button class="btn btn-primary" id="reset" type="submit">[[reset_password:reset-password]]</button>
</form>
</div>
{{{ else }}}
<div class="card">
<div class="card-header">
<h5 class="mb-0">[[reset_password:wrong-reset-code.title]]</h5>
</div>
<div class="card-body">
<p>[[reset_password:wrong-reset-code.message]]</p>
</div>
</div>
{{{ end }}}
<div class="alert alert-success alert-dismissible hidden" id="success">
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
<strong>[[reset_password:password-changed.title]]</strong>
<p>[[reset_password:password-changed.message]]</p>
</div>
<div class="alert alert-warning hidden" id="notice">
<strong></strong>
<p></p>
</div>
<form onsubmit="return false;" id="reset-form">
<div class="mb-3">
<label class="form-label" for="password">[[reset_password:new-password]]</label>
<input class="form-control" type="password" placeholder="[[reset_password:new-password]]" id="password" /><br />
</div>
<div class="mb-3">
<label class="form-label" for="repeat">[[reset_password:repeat-password]]</label>
<input class="form-control" type="password" placeholder="[[reset_password:repeat-password]]" id="repeat" /><br />
</div>
<button class="btn btn-primary btn-block" id="reset" type="submit">[[reset_password:reset-password]]</button>
</form>
</div>
{{{ else }}}
<div class="card text-bg-danger">
<h5 class="card-header">
[[reset_password:wrong-reset-code.title]]
</h5>
<div class="card-body">
<p>[[reset_password:wrong-reset-code.message]]</p>
</div>
</div>
{{{ end }}}
</div>