Skip to content

Commit

Permalink
Move mapping after member is created
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianbinzhu committed Oct 5, 2023
1 parent 1b3e049 commit 0ff8f4d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
16 changes: 8 additions & 8 deletions src/Control/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,6 @@ public function acs()
$member->$field = $attributes[$claim][0];
}

$mapUserGroup = Config::inst()->get(SAMLConfiguration::class, 'map_user_group');
// Map user groups
if ($mapUserGroup) {
$mapper = SAMLUserGroupMapper::singleton();

$member = $mapper->map($attributes, $member);
}

$member->SAMLSessionIndex = $auth->getSessionIndex();

// This will trigger LDAP update through LDAPMemberExtension::memberLoggedIn, if the LDAP module is installed.
Expand All @@ -219,6 +211,14 @@ public function acs()
// Both SAML and LDAP identify Members by the same GUID field.
$member->write();

$mapUserGroup = Config::inst()->get(SAMLConfiguration::class, 'map_user_group');
// Map user groups
if ($mapUserGroup) {
$mapper = SAMLUserGroupMapper::singleton();

$member = $mapper->map($attributes, $member);
}

// Hook for modifying login behaviour
$this->extend('updateLogin');

Expand Down
5 changes: 0 additions & 5 deletions src/Helpers/SAMLUserGroupMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ public function map($attributes, $member): Member
$group->write();
}

// Add group to user and make sure user has been created
if (!$member->exists()) {
$member->write();
}

$member->Groups()->add($group);
}

Expand Down

0 comments on commit 0ff8f4d

Please sign in to comment.