1 | <?php |
||
19 | abstract class BaseGuard |
||
20 | implements GaurdContract |
||
|
|||
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 | * @inheritdoc |
||
119 | */ |
||
120 | 5 | public function user() |
|
137 | |||
138 | /** |
||
139 | * @inheritdoc |
||
140 | */ |
||
141 | 12 | public function getBearerToken($isRefresh = false) |
|
150 | |||
151 | /** |
||
152 | * @inheritdoc |
||
153 | */ |
||
154 | 2 | public function validate(array $credentials = []) |
|
162 | |||
163 | /** |
||
164 | * Determine if the user matches the credentials. |
||
165 | * |
||
166 | * @param Authenticatable|null $user |
||
167 | * @param array $credentials |
||
168 | * @return bool |
||
169 | */ |
||
170 | 6 | protected function hasValidCredentials($user, $credentials) |
|
174 | |||
175 | /** |
||
176 | * Sets the Request |
||
177 | * |
||
178 | * @param Request $request |
||
179 | */ |
||
180 | 1 | public function setRequest(Request $request) |
|
184 | |||
185 | /** |
||
186 | * Gets the request |
||
187 | * |
||
188 | * @return Request |
||
189 | */ |
||
190 | 1 | public function getRequest() |
|
194 | |||
195 | /** |
||
196 | * Attempt to authenticate a user using the given credentials. |
||
197 | * |
||
198 | * @param array $credentials |
||
199 | * @return bool|Token |
||
200 | */ |
||
201 | 4 | public function attempt(array $credentials = []) |
|
212 | |||
213 | /** |
||
214 | * Generate a new token |
||
215 | * |
||
216 | * @param SubjectContract $user |
||
217 | * @return Token |
||
218 | */ |
||
219 | 4 | protected function generateToken(SubjectContract $user) |
|
230 | } |
||
231 |