|
|
@ -107,6 +107,8 @@ class UserService extends SiteService {
|
|
|
|
canReport: userDefinition.canReport || true,
|
|
|
|
canReport: userDefinition.canReport || true,
|
|
|
|
canAuthorPosts: userDefinition.canAuthorPosts || false,
|
|
|
|
canAuthorPosts: userDefinition.canAuthorPosts || false,
|
|
|
|
canAuthorPages: userDefinition.canAuthorPages || false,
|
|
|
|
canAuthorPages: userDefinition.canAuthorPages || false,
|
|
|
|
|
|
|
|
canPublishPosts: userDefinition.canPublishPosts || false,
|
|
|
|
|
|
|
|
canPublishPages: userDefinition.canPublishPages || false,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
user.optIn = {
|
|
|
|
user.optIn = {
|
|
|
@ -248,6 +250,8 @@ class UserService extends SiteService {
|
|
|
|
'permissions.canReport': userDefinition.canReport === 'on',
|
|
|
|
'permissions.canReport': userDefinition.canReport === 'on',
|
|
|
|
'permissions.canAuthorPages': userDefinition.canAuthorPages === 'on',
|
|
|
|
'permissions.canAuthorPages': userDefinition.canAuthorPages === 'on',
|
|
|
|
'permissions.canAuthorPosts': userDefinition.canAuthorPosts === 'on',
|
|
|
|
'permissions.canAuthorPosts': userDefinition.canAuthorPosts === 'on',
|
|
|
|
|
|
|
|
'permissions.canPublishPages': userDefinition.canPublishPages === 'on',
|
|
|
|
|
|
|
|
'permissions.canPublishPosts': userDefinition.canPublishPosts === 'on',
|
|
|
|
|
|
|
|
|
|
|
|
'optIn.system': userDefinition.optInSystem === 'on',
|
|
|
|
'optIn.system': userDefinition.optInSystem === 'on',
|
|
|
|
'optIn.marketing': userDefinition.optInMarketing === 'on',
|
|
|
|
'optIn.marketing': userDefinition.optInMarketing === 'on',
|
|
|
@ -290,19 +294,22 @@ class UserService extends SiteService {
|
|
|
|
const accountUsername = await this.filterUsername(accountEmail);
|
|
|
|
const accountUsername = await this.filterUsername(accountEmail);
|
|
|
|
|
|
|
|
|
|
|
|
this.log.debug('locating user record', { accountEmail, accountUsername });
|
|
|
|
this.log.debug('locating user record', { accountEmail, accountUsername });
|
|
|
|
const user = await User
|
|
|
|
let user = await User
|
|
|
|
.findOne({
|
|
|
|
.findOne({
|
|
|
|
$or: [
|
|
|
|
$or: [
|
|
|
|
{ email: accountEmail },
|
|
|
|
{ email: accountEmail },
|
|
|
|
{ username_lc: accountUsername },
|
|
|
|
{ username_lc: accountUsername },
|
|
|
|
]
|
|
|
|
]
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.select('+passwordSalt +password +flags +optIn +permissions')
|
|
|
|
.select('+passwordSalt +password +flags +optIn +permissions');
|
|
|
|
.lean();
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
if (!user) {
|
|
|
|
throw new SiteError(404, 'Member credentials are invalid');
|
|
|
|
throw new SiteError(404, 'Member credentials are invalid');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user = user.toObject();
|
|
|
|
|
|
|
|
this.log.debug('user debug', { user });
|
|
|
|
|
|
|
|
|
|
|
|
const maskedPassword = crypto.maskPassword(
|
|
|
|
const maskedPassword = crypto.maskPassword(
|
|
|
|
user.passwordSalt,
|
|
|
|
user.passwordSalt,
|
|
|
|
account.password,
|
|
|
|
account.password,
|
|
|
@ -407,10 +414,19 @@ class UserService extends SiteService {
|
|
|
|
if (!user) {
|
|
|
|
if (!user) {
|
|
|
|
throw new SiteError(404, 'Member account not found');
|
|
|
|
throw new SiteError(404, 'Member account not found');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
user.type = 'User';
|
|
|
|
user.type = 'User';
|
|
|
|
|
|
|
|
this.decorateUserObject(user);
|
|
|
|
|
|
|
|
|
|
|
|
return user;
|
|
|
|
return user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
decorateUserObject (user) {
|
|
|
|
|
|
|
|
user.hasAuthorPermissions = user.permissions.canAuthorPages || user.permissions.canAuthorPosts;
|
|
|
|
|
|
|
|
user.hasPublishPermissions = user.permissions.canPublishPages || user.permissions.canPublishPosts;
|
|
|
|
|
|
|
|
user.hasAuthorDashboard = user.hasAuthorPermissions || user.hasPublishPermissions;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async getUserAccounts (pagination, username) {
|
|
|
|
async getUserAccounts (pagination, username) {
|
|
|
|
let search = { };
|
|
|
|
let search = { };
|
|
|
|
if (username) {
|
|
|
|
if (username) {
|
|
|
|