25 lines
949 B
JavaScript
25 lines
949 B
JavaScript
|
|
const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
|
const {models} = require('vn-loopback/server/server');
|
|
|
|
module.exports = Self => {
|
|
require('../methods/account/sync')(Self);
|
|
require('../methods/account/sync-by-id')(Self);
|
|
require('../methods/account/sync-all')(Self);
|
|
require('../methods/account/login')(Self);
|
|
require('../methods/account/logout')(Self);
|
|
require('../methods/account/change-password')(Self);
|
|
require('../methods/account/set-password')(Self);
|
|
|
|
Self.setUnverifiedPassword = async(id, pass, options) => {
|
|
const {emailVerified} = await models.VnUser.findById(id, {fields: ['emailVerified']}, options);
|
|
if (emailVerified) {
|
|
throw new ForbiddenError(
|
|
'Through this procedure, it is not possible to modify the password of users with verified email'
|
|
);
|
|
}
|
|
|
|
await models.VnUser.setPassword(id, pass, options);
|
|
};
|
|
};
|