salix/modules/account/back/models/account.js

22 lines
896 B
JavaScript
Raw Normal View History

2023-01-31 13:57:24 +00:00
const ForbiddenError = require('vn-loopback/util/forbiddenError');
const {models} = require('vn-loopback/server/server');
2023-01-31 13:57:24 +00:00
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 user = await models.VnUser.findById(id, null, options);
2024-02-23 08:31:01 +00:00
if (user.emailVerified) throw new ForbiddenError('This password can only be changed by the user themselves');
await models.VnUser.setPassword(id, pass, options);
await user.updateAttribute('emailVerified', true, options);
};
2023-01-31 13:57:24 +00:00
};