Selaa lähdekoodia

Merge pull request #4245 from Emile840/master

fix issue #4222
Lauri Ojansivu 3 vuotta sitten
vanhempi
sitoutus
e305bf019f
1 muutettua tiedostoa jossa 14 lisäystä ja 4 poistoa
  1. 14 4
      models/users.js

+ 14 - 4
models/users.js

@@ -1683,10 +1683,20 @@ if (Meteor.isServer) {
     // If ldap, bypass the inviation code if the self registration isn't allowed.
     // 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
     // TODO : pay attention if ldap field in the user model change to another content ex : ldap field to connection_type
     if (doc.authenticationMethod !== 'ldap' && disableRegistration) {
     if (doc.authenticationMethod !== 'ldap' && disableRegistration) {
-      const invitationCode = InvitationCodes.findOne({
-        code: doc.profile.icode,
-        valid: true,
-      });
+      let invitationCode = null;
+      if(doc.authenticationMethod.toLowerCase() == 'oauth2')
+      { // OIDC authentication mode
+        invitationCode = InvitationCodes.findOne({
+          email: doc.emails[0].address.toLowerCase(),
+          valid: true,
+        });
+      }
+      else{
+        invitationCode = InvitationCodes.findOne({
+          code: doc.profile.icode,
+          valid: true,
+        });
+      }
       if (!invitationCode) {
       if (!invitationCode) {
         throw new Meteor.Error('error-invitation-code-not-exist');
         throw new Meteor.Error('error-invitation-code-not-exist');
       } else {
       } else {