Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add role handling that includes internal role system #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Auth/SamlAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public function authenticate(){

//Check if username and email are set
if (!empty($username) && !empty($email)) {

//Create user by having email as username
$this->userInfo = new SamlUserProvider($username, $email, $fullname);
//Create user
$userProfile = $this->userCacheDecorator->getByUsername($username);
$this->userInfo = new SamlUserProvider($username, $email, $fullname, $userProfile ?: array());
return true;

} else {
Expand Down
18 changes: 14 additions & 4 deletions User/SamlUserProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,26 @@ class SamlUserProvider implements UserProviderInterface
*/
protected $name = '';

/**
* User profile if the user already exists
*
* @access private
* @var array
*/
private $userProfile = array();

/**
* Constructor
*
* @access public
* @param string $username
*/
public function __construct($username, $email, $name, $role)
public function __construct($username, $email, $name, array $userProfile = array())
{
$this->username = $username;
$this->email = $email;
$this->name = $name;
$this->role = $role;
$this->userProfile = $userProfile;
}

/**
Expand Down Expand Up @@ -96,8 +104,10 @@ public function getExternalId()
*/
public function getRole()
{
//return Role::APP_USER;
return $this->role;
if(isset($this->userProfile['role'])){
return $this->userProfile['role'];
}
return Role::APP_USER;
}

/**
Expand Down