budibase/packages/server/utilities/injectedPlugins/createUser.js

18 lines
524 B
JavaScript

module.exports = ({ masterAppInternal, instanceKey }) => async ({ user }) => {
const { bbMaster } = masterAppInternal;
const masterUser = bbMaster.recordApi
.getNew(`${newAppKey}/users`, "user");
masterUser.name = user.name;
masterUser.createdByMaster = false;
masterUser.instance = await bbMaster.recordApi
.load(instanceKey);
masterUser.active = user.enabled;
await bbMaster.recordApi.save(masterUser);
}