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('This password can only be changed by the user themselves'); await models.VnUser.setPassword(id, pass, options); }; };