diff options
Diffstat (limited to 'app/User')
-rw-r--r-- | app/User/Avatar/LetterAvatarProvider.php | 2 | ||||
-rw-r--r-- | app/User/OAuthUserProvider.php | 14 | ||||
-rw-r--r-- | app/User/ReverseProxyUserProvider.php | 21 |
3 files changed, 23 insertions, 14 deletions
diff --git a/app/User/Avatar/LetterAvatarProvider.php b/app/User/Avatar/LetterAvatarProvider.php index b7a95f41..727f9109 100644 --- a/app/User/Avatar/LetterAvatarProvider.php +++ b/app/User/Avatar/LetterAvatarProvider.php @@ -142,7 +142,7 @@ class LetterAvatarProvider extends Base implements AvatarProviderInterface // Make hash more sensitive for short string like 'a', 'b', 'c' $str .= 'x'; - $max = intval(9007199254740991 / $seed2); + $max = intval(PHP_INT_MAX / $seed2); for ($i = 0, $ilen = mb_strlen($str, 'UTF-8'); $i < $ilen; $i++) { if ($hash > $max) { diff --git a/app/User/OAuthUserProvider.php b/app/User/OAuthUserProvider.php index dec26250..e5fedcca 100644 --- a/app/User/OAuthUserProvider.php +++ b/app/User/OAuthUserProvider.php @@ -13,14 +13,6 @@ use Kanboard\Core\User\UserProviderInterface; abstract class OAuthUserProvider implements UserProviderInterface { /** - * Get external id column name - * - * @access public - * @return string - */ - abstract public function getExternalIdColumn(); - - /** * User properties * * @access protected @@ -69,7 +61,7 @@ abstract class OAuthUserProvider implements UserProviderInterface */ public function getExternalId() { - return $this->user['id']; + return isset($this->user['id']) ? $this->user['id'] : ''; } /** @@ -102,7 +94,7 @@ abstract class OAuthUserProvider implements UserProviderInterface */ public function getName() { - return $this->user['name']; + return isset($this->user['name']) ? $this->user['name'] : ''; } /** @@ -113,7 +105,7 @@ abstract class OAuthUserProvider implements UserProviderInterface */ public function getEmail() { - return $this->user['email']; + return isset($this->user['email']) ? $this->user['email'] : ''; } /** 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; } /** |