Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from DerManoMann/default_roles
Browse files Browse the repository at this point in the history
Allow to set default roles on authenticated user
  • Loading branch information
DerManoMann committed Jan 27, 2016
2 parents d160796 + 71acecd commit 62c94d3
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct($providerKey, UserProviderInterface $userProvider, $
$this->userProvider = $userProvider;
$this->ldap = $ldap;
$this->logger = $logger;
$this->options = $options;
$this->options = array_merge(array('roles' => array()), $options);
}

/**
Expand All @@ -55,7 +55,7 @@ public function authenticate(TokenInterface $token)
{
$user = $this->userProvider->loadUserByUsername($token->getUsername());
if ($user && $this->ldapAuth($token->getUserName(), $token->getCredentials())) {
return new UsernamePasswordToken($user, null, $this->providerKey, array_unique(array_merge($token->getRoles(), $user->getRoles())));
return new UsernamePasswordToken($user, null, $this->providerKey, array_unique(array_merge($this->options['roles'], $token->getRoles(), $user->getRoles())));
}

throw new AuthenticationException('Ldap authentication failed.');
Expand Down

0 comments on commit 62c94d3

Please sign in to comment.