const app = require('vn-loopback/server/server'); const UserError = require('vn-loopback/util/user-error'); module.exports = function(Self, options) { require('../methods/account-linker/test')(Self); Self.once('attached', function() { app.models.AccountConfig.addLinker(Self); }); /** * Mixin for account linkers. * * @property {Array} $ * @property {Object} accountConfig * @property {Object} mailConfig */ let Mixin = { /** * Initalizes the linker. */ async init() {}, /** * Deinitalizes the linker. */ async deinit() {}, /** * Get users to synchronize. * * @param {Set} usersToSync Set where users are added */ async getUsers(usersToSync) {}, /** * Synchronizes a user. * * @param {Object} info User information * @param {String} userName The user name * @param {String} password Thepassword */ async syncUser(info, userName, password) {}, /** * Synchronizes user groups. * * @param {Object} info User information * @param {String} userName The user name */ async syncUserGroups(info, userName) {}, /** * Synchronizes roles. */ async syncRoles() {}, /** * Tests linker configuration. */ async test() { try { await this.init(); await this.deinit(); } catch (e) { let err = new UserError(e.message); err.name = e.name; throw err; } } }; for (let method in Mixin) { if (!Self.prototype[method]) Self.prototype[method] = Mixin[method]; } };