2020-11-12 22:20:25 +00:00
|
|
|
|
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
const UserError = require('vn-loopback/util/user-error');
|
|
|
|
|
|
|
|
module.exports = function(Self, options) {
|
2023-11-20 17:39:37 +00:00
|
|
|
require('../methods/account-linker/test')(Self);
|
2020-11-12 22:20:25 +00:00
|
|
|
|
|
|
|
Self.once('attached', function() {
|
2023-11-20 17:39:37 +00:00
|
|
|
app.models.AccountConfig.addLinker(Self);
|
2020-11-12 22:20:25 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
2023-11-20 17:39:37 +00:00
|
|
|
* Mixin for account linkers.
|
2020-11-12 22:20:25 +00:00
|
|
|
*
|
|
|
|
* @property {Array<Model>} $
|
|
|
|
* @property {Object} accountConfig
|
|
|
|
* @property {Object} mailConfig
|
|
|
|
*/
|
|
|
|
let Mixin = {
|
|
|
|
/**
|
2023-11-20 17:39:37 +00:00
|
|
|
* Initalizes the linker.
|
2020-11-12 22:20:25 +00:00
|
|
|
*/
|
|
|
|
async init() {},
|
|
|
|
|
|
|
|
/**
|
2023-11-20 17:39:37 +00:00
|
|
|
* Deinitalizes the linker.
|
2020-11-12 22:20:25 +00:00
|
|
|
*/
|
|
|
|
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() {},
|
|
|
|
|
|
|
|
/**
|
2023-11-20 17:39:37 +00:00
|
|
|
* Tests linker configuration.
|
2020-11-12 22:20:25 +00:00
|
|
|
*/
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
};
|