summaryrefslogtreecommitdiffstats
path: root/models/users.js
diff options
context:
space:
mode:
authorguillaume <guillaume.cassou@supinfo.com>2018-10-09 14:14:39 +0200
committerguillaume <guillaume.cassou@supinfo.com>2018-10-09 14:14:39 +0200
commit3b4f285fea4a90ee96bfce855e1539adcec9b7aa (patch)
tree61cbf1212c8d4052cf2bd3c37a497f1d8b204140 /models/users.js
parent5b8c642d8fb16e00000a1d92bcd3a5c6bbd07bce (diff)
downloadwekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.tar.gz
wekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.tar.bz2
wekan-3b4f285fea4a90ee96bfce855e1539adcec9b7aa.zip
add ldap support | simplify authentications
Diffstat (limited to 'models/users.js')
-rw-r--r--models/users.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/models/users.js b/models/users.js
index 27d3e9fa..9a195850 100644
--- a/models/users.js
+++ b/models/users.js
@@ -127,10 +127,10 @@ Users.attachSchema(new SimpleSchema({
type: Boolean,
optional: true,
},
- // TODO : write a migration and check if using a ldap parameter is better than a connection_type parameter
- ldap: {
- type: Boolean,
- optional: true,
+ 'authenticationMethod': {
+ type: String,
+ optional: false,
+ defaultValue: 'password',
},
}));
@@ -499,6 +499,7 @@ if (Meteor.isServer) {
user.emails = [{ address: email, verified: true }];
const initials = user.services.oidc.fullname.match(/\b[a-zA-Z]/g).join('').toUpperCase();
user.profile = { initials, fullname: user.services.oidc.fullname };
+ user['authenticationMethod'] = 'oauth2';
// see if any existing user has this email address or username, otherwise create new
const existingUser = Meteor.users.findOne({$or: [{'emails.address': email}, {'username':user.username}]});
@@ -511,6 +512,7 @@ if (Meteor.isServer) {
existingUser.emails = user.emails;
existingUser.username = user.username;
existingUser.profile = user.profile;
+ existingUser['authenticationMethod'] = user['authenticationMethod'];
Meteor.users.remove({_id: existingUser._id}); // remove existing record
return existingUser;
@@ -525,7 +527,7 @@ if (Meteor.isServer) {
// If ldap, bypass the inviation code if the self registration isn't allowed.
// TODO : pay attention if ldap field in the user model change to another content ex : ldap field to connection_type
if (options.ldap || !disableRegistration) {
- user.ldap = true;
+ user['authenticationMethod'] = 'ldap';
return user;
}
@@ -645,7 +647,7 @@ if (Meteor.isServer) {
const disableRegistration = Settings.findOne().disableRegistration;
// If ldap, bypass the inviation code if the self registration isn't allowed.
// TODO : pay attention if ldap field in the user model change to another content ex : ldap field to connection_type
- if (!doc.ldap && disableRegistration) {
+ if (doc['authenticationMethod'] !== 'ldap' && disableRegistration) {
const invitationCode = InvitationCodes.findOne({code: doc.profile.icode, valid: true});
if (!invitationCode) {
throw new Meteor.Error('error-invitation-code-not-exist');