Blame view
imports/server/accounts/creation.js
1.01 KB
ff976df49
|
1 2 3 4 |
import _ from 'lodash'; import { Accounts } from 'meteor/accounts-base'; import { SimpleSchema } from 'meteor/aldeed:simple-schema'; import { ValidatedMethod } from 'meteor/mdg:validated-method'; |
b7054c9b2
|
5 |
|
ff976df49
|
6 7 |
import { Orgs } from '/imports/collections/orgs/index'; import { Users } from '/imports/collections/users/index'; |
ff976df49
|
8 9 10 11 12 |
Accounts.validateNewUser((user) => { return !!user; }); Accounts.onCreateUser((options, user) => { |
878ca8a15
|
13 |
|
b7054c9b2
|
14 15 |
if(options.orgSlug){ orgId = Orgs.insert({ |
316564385
|
16 |
slug: options.orgSlug.replace(" ", "-").toLowerCase(), |
b7054c9b2
|
17 18 19 20 21 22 23 24 |
name: options.orgName, setup: 1, users: [{ userId: user._id, role: Users.roles.ADMIN, }], }); } |
316564385
|
25 26 |
_.assign(user, { |
b7054c9b2
|
27 28 |
role: Users.roles.ADMIN, orgId: orgId, |
878ca8a15
|
29 30 |
firstName: options.profile.name.first, lastName: options.profile.name.last, |
b7054c9b2
|
31 32 |
}); return user; |
ff976df49
|
33 |
}); |