1 | <?php |
||
19 | abstract class BaseGuard |
||
20 | implements GaurdContract, GuardInterface |
||
|
|||
21 | { |
||
22 | use GuardHelpers; |
||
23 | |||
24 | const JWT_GUARD_CLAIM = 'grd'; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | protected $id; |
||
30 | |||
31 | /** |
||
32 | * @var Request |
||
33 | */ |
||
34 | protected $request; |
||
35 | |||
36 | /** |
||
37 | * Constructor |
||
38 | * |
||
39 | * @param UserProvider $provider |
||
40 | * @param Request $request |
||
41 | */ |
||
42 | 22 | public function __construct($id, UserProvider $provider, Request $request) |
|
48 | |||
49 | /** |
||
50 | * Returns the adapter class name to use |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | 15 | public function getAdapterFactoryClass() |
|
70 | |||
71 | /** |
||
72 | * Returns the adapter factory object |
||
73 | * |
||
74 | * @return AdapterFactoryContract |
||
75 | */ |
||
76 | 15 | protected function getAdapterFactory() |
|
86 | |||
87 | /** |
||
88 | * Returns a token processor from the adapter factory |
||
89 | * |
||
90 | * @return ProcessorContract |
||
91 | */ |
||
92 | 11 | protected function getProcessor() |
|
96 | |||
97 | /** |
||
98 | * Returns a token generator from the adapter factory |
||
99 | * |
||
100 | * @return GeneratorContract |
||
101 | */ |
||
102 | 7 | protected function getGenerator() |
|
106 | |||
107 | /** |
||
108 | * Gets the provider |
||
109 | * |
||
110 | * @return UserProvider |
||
111 | */ |
||
112 | 14 | public function getProvider() |
|
116 | |||
117 | |||
118 | /** |
||
119 | * @inheritdoc |
||
120 | */ |
||
121 | 4 | public function refresh(AuthFactory $auth) |
|
130 | |||
131 | /** |
||
132 | * Refresh the token |
||
133 | * @param Token $token |
||
134 | * @return Token|boolean New token or false if old token can't be verified |
||
135 | */ |
||
136 | 3 | public function refreshToken(Token $token) |
|
146 | |||
147 | /** |
||
148 | * @inheritdoc |
||
149 | */ |
||
150 | 3 | public function universalUserLogin(AuthFactory $auth) |
|
163 | |||
164 | /** |
||
165 | * @inheritdoc |
||
166 | */ |
||
167 | 5 | public function user() |
|
184 | |||
185 | /** |
||
186 | * @inheritdoc |
||
187 | */ |
||
188 | 12 | public function getBearerToken($isRefresh = false) |
|
197 | |||
198 | /** |
||
199 | * @inheritdoc |
||
200 | */ |
||
201 | 2 | public function validate(array $credentials = []) |
|
209 | |||
210 | /** |
||
211 | * Determine if the user matches the credentials. |
||
212 | * |
||
213 | * @param Authenticatable|null $user |
||
214 | * @param array $credentials |
||
215 | * @return bool |
||
216 | */ |
||
217 | 6 | protected function hasValidCredentials($user, $credentials) |
|
221 | |||
222 | /** |
||
223 | * Sets the Request |
||
224 | * |
||
225 | * @param Request $request |
||
226 | */ |
||
227 | 1 | public function setRequest(Request $request) |
|
231 | |||
232 | /** |
||
233 | * Gets the request |
||
234 | * |
||
235 | * @return Request |
||
236 | */ |
||
237 | 1 | public function getRequest() |
|
241 | |||
242 | /** |
||
243 | * Attempt to authenticate a user using the given credentials. |
||
244 | * |
||
245 | * @param array $credentials |
||
246 | * @return bool|Token |
||
247 | */ |
||
248 | 4 | public function attempt(array $credentials = []) |
|
259 | |||
260 | /** |
||
261 | * Generate a new token |
||
262 | * |
||
263 | * @param SubjectContract $user |
||
264 | * @return Token |
||
265 | */ |
||
266 | 4 | private function generateToken(SubjectContract $user) |
|
277 | } |
||
278 |