1 | <?php |
||
27 | class RedmineUserProvider implements UserProviderInterface, CredentialsUserProviderInterface |
||
28 | { |
||
29 | /** |
||
30 | * @var UserFactoryInterface |
||
31 | */ |
||
32 | protected $userFactory; |
||
33 | |||
34 | /** |
||
35 | * @var RedmineApiClientInterface |
||
36 | */ |
||
37 | protected $apiClient; |
||
38 | |||
39 | /** |
||
40 | * @var UserRepositoryInterface |
||
41 | */ |
||
42 | protected $userRepository = false; |
||
43 | |||
44 | /** |
||
45 | * @var array |
||
46 | */ |
||
47 | protected $allowedDomains; |
||
48 | |||
49 | /** |
||
50 | * @var LoggerInterface |
||
51 | */ |
||
52 | protected $logger; |
||
53 | |||
54 | /** |
||
55 | * Class constructor |
||
56 | * |
||
57 | * @param array $allowedDomains |
||
58 | * @param LoggerInterface $logger |
||
59 | */ |
||
60 | 11 | public function __construct(array $allowedDomains, LoggerInterface $logger) |
|
65 | |||
66 | /** |
||
67 | * Set User object factory |
||
68 | * |
||
69 | * @param UserFactoryInterface $userFactory |
||
70 | */ |
||
71 | 11 | public function setUserFactory(UserFactoryInterface $userFactory) |
|
75 | |||
76 | /** |
||
77 | * Set the Redmine API client |
||
78 | * |
||
79 | * @param RedmineApiClientInterface $apiClient |
||
80 | */ |
||
81 | 11 | public function setApiClient(RedmineApiClientInterface $apiClient) |
|
85 | |||
86 | /** |
||
87 | * Set the User repository |
||
88 | * |
||
89 | * @param UserRepositoryInterface $userRepository |
||
90 | */ |
||
91 | 1 | public function setUserRepository(UserRepositoryInterface $userRepository) |
|
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | 6 | public function loadUserByCredentials(string $username, string $password): UserInterface |
|
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | 1 | public function loadUserByUsername($username) |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 1 | public function refreshUser(UserInterface $user) |
|
144 | |||
145 | /** |
||
146 | * {@inheritdoc} |
||
147 | */ |
||
148 | 2 | public function supportsClass($class) |
|
157 | |||
158 | /** |
||
159 | * Control if the user's email address domain is allowed |
||
160 | * |
||
161 | * @param array $data |
||
162 | */ |
||
163 | 4 | private function checkUserDomain(array $data) |
|
180 | |||
181 | /** |
||
182 | * Retrieve the user or create it |
||
183 | * |
||
184 | * @param array $data |
||
185 | * |
||
186 | * @return RedmineUser |
||
187 | */ |
||
188 | 3 | private function getUser(array $data): RedmineUser |
|
214 | } |
||
215 |