Skip to content

Commit

Permalink
fix: fixed new user check in alias pre save for ubuntu demo
Browse files Browse the repository at this point in the history
  • Loading branch information
titanism committed Apr 23, 2024
1 parent 827e51a commit c8eed66
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/models/aliases.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Aliases.pre('save', async function (next) {
: member.user.id === alias.user.toString()
);

if (!member && domain.is_global)
if (!member && (alias.is_new_user || domain.is_global))
member = {
user: {
_id: user ? user._id : alias.user,
Expand All @@ -491,6 +491,10 @@ Aliases.pre('save', async function (next) {
group: 'user'
};

//
// NOTE: because the user model has a pre save hook that adds a domain member
// but populate above is trying to populate it, we can assume it's new
//
if (!member)
throw Boom.notFound(i18n.translateError('INVALID_MEMBER', alias.locale));

Expand Down

0 comments on commit c8eed66

Please sign in to comment.