forked from doubledare/accounts-ui-twbootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accounts_ui.js
41 lines (35 loc) · 1.16 KB
/
accounts_ui.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
if (!Accounts.ui)
Accounts.ui = {};
if (!Accounts.ui._options) {
Accounts.ui._options = {
requestPermissions: {}
};
}
Accounts.ui.config = function(options) {
if (options.passwordSignupFields) {
if (_.contains([
"USERNAME_AND_EMAIL",
"USERNAME_AND_OPTIONAL_EMAIL",
"USERNAME_ONLY",
"EMAIL_ONLY"
], options.passwordSignupFields)) {
if (Accounts.ui._options.passwordSignupFields)
throw new Error("Can't set `passwordSignupFields` more than once");
else
Accounts.ui._options.passwordSignupFields = options.passwordSignupFields;
} else {
throw new Error("Invalid option for `passwordSignupFields`: " + options.passwordSignupFields);
}
}
if (options.requestPermissions) {
_.each(options.requestPermissions, function (scope, service) {
if (Accounts.ui._options.requestPermissions[service])
throw new Error("Can't set `requestPermissions` more than once for " + service);
else
Accounts.ui._options.requestPermissions[service] = scope;
});
}
};
Accounts.ui._passwordSignupFields = function () {
return Accounts.ui._options.passwordSignupFields || "EMAIL_ONLY";
};