Source of file UserEntity.php
Size: 1,175 Bytes - Last Modified: 2022-02-21T10:00:46+00:00
/var/www/docs.ssmods.com/process/src/src/Entities/UserEntity.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | <?php namespace AdvancedLearning\Oauth2Server\Entities; use AdvancedLearning\Oauth2Server\Extensions\GroupExtension; use League\OAuth2\Server\Entities\Traits\EntityTrait; use League\OAuth2\Server\Entities\UserEntityInterface; use SilverStripe\Security\Group; use SilverStripe\Security\Member; class UserEntity implements UserEntityInterface { use EntityTrait; protected $member; public function __construct(Member $member) { $this->member = $member; $this->setIdentifier($member->Email); } /** * Get the Member associated with this ClientEntity. * * @return Member */ public function getMember() { return $this->member; } /** * Checks whether the member has a scope. Only works if the GroupExtension has been configured. * * @param string $scope * @return bool */ public function hasScope(string $scope): bool { // always return true if extensions not configured return !Group::create()->hasExtension(GroupExtension::class) || $this->getMember()->Groups()->filter([ 'Scopes.Name' => $scope ])->count() > 0; } } |