Skip to content

Commit

Permalink
feat: allow no-reply usernames but make them disabled if admin
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Sep 14, 2023
1 parent 84bd5a1 commit 81db5eb
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/models/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,19 @@ Aliases.pre('save', async function (next) {

const string = alias.name.replace(/[^\da-z]/g, '');

// prevent users from registering no-reply usernames
if (NO_REPLY_USERNAMES.has(string)) {
const err = Boom.badRequest(
i18n.translateError('NO_REPLY_USERNAME_DISALLOWED', alias.locale)
);
err.is_reserved_word = true;
throw err;
}
if (member.group === 'admin') {
// always disable no-reply usernames
if (NO_REPLY_USERNAMES.has(string)) alias.is_enabled = false;
} else {
// prevent users from registering no-reply usernames
if (NO_REPLY_USERNAMES.has(string)) {
const err = Boom.badRequest(
i18n.translateError('NO_REPLY_USERNAME_DISALLOWED', alias.locale)
);
err.is_reserved_word = true;
throw err;
}

if (member.group !== 'admin') {
// alias name cannot be a wildcard "*" if the user is not an admin
if (alias.name === '*')
throw Boom.badRequest(
Expand Down

0 comments on commit 81db5eb

Please sign in to comment.