summaryrefslogtreecommitdiff
path: root/app/User
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-02 17:44:45 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-02 17:44:45 -0400
commit43337d58c0be097ca510f2abd1497f13f25bda5b (patch)
tree8a4e941c2eae7b0b29ab1c0b4cd086aa853c5e87 /app/User
parent10d577ad9d1b2976cdb080a7d7df3944e0db170f (diff)
Preserve role for existing users when using ReverseProxy authentication
Diffstat (limited to 'app/User')
-rw-r--r--app/User/ReverseProxyUserProvider.php21
1 files changed, 19 insertions, 2 deletions
diff --git a/app/User/ReverseProxyUserProvider.php b/app/User/ReverseProxyUserProvider.php
index 723b8155..34d2187d 100644
--- a/app/User/ReverseProxyUserProvider.php
+++ b/app/User/ReverseProxyUserProvider.php
@@ -22,14 +22,23 @@ class ReverseProxyUserProvider implements UserProviderInterface
protected $username = '';
/**
+ * User profile if the user already exists
+ *
+ * @access protected
+ * @var array
+ */
+ private $userProfile = array();
+
+ /**
* Constructor
*
* @access public
* @param string $username
*/
- public function __construct($username)
+ public function __construct($username, array $userProfile = array())
{
$this->username = $username;
+ $this->userProfile = $userProfile;
}
/**
@@ -84,7 +93,15 @@ class ReverseProxyUserProvider implements UserProviderInterface
*/
public function getRole()
{
- return REVERSE_PROXY_DEFAULT_ADMIN === $this->username ? Role::APP_ADMIN : Role::APP_USER;
+ if (REVERSE_PROXY_DEFAULT_ADMIN === $this->username) {
+ return Role::APP_ADMIN;
+ }
+
+ if (isset($this->userProfile['role'])) {
+ return $this->userProfile['role'];
+ }
+
+ return Role::APP_USER;
}
/**