1 | <?php |
||
21 | abstract class BaseGuard |
||
22 | implements GaurdContract, GuardInterface |
||
|
|||
23 | { |
||
24 | use GuardHelpers; |
||
25 | |||
26 | /** |
||
27 | * @var Request |
||
28 | */ |
||
29 | protected $request; |
||
30 | |||
31 | /** |
||
32 | * Constructor |
||
33 | * |
||
34 | * @param UserProvider $provider |
||
35 | * @param Request $request |
||
36 | */ |
||
37 | 13 | public function __construct(UserProvider $provider, Request $request) |
|
42 | |||
43 | /** |
||
44 | * Returns the adapter class name to use |
||
45 | * |
||
46 | * @return string |
||
47 | */ |
||
48 | 7 | public function getAdapterFactoryClass() |
|
64 | |||
65 | /** |
||
66 | * Returns the adapter factory object |
||
67 | * |
||
68 | * @return AdapterFactoryContract |
||
69 | */ |
||
70 | 7 | protected function getAdapterFactory() |
|
80 | |||
81 | /** |
||
82 | * Returns a token processor from the adapter factory |
||
83 | * |
||
84 | * @return ProcessorContract |
||
85 | */ |
||
86 | 3 | protected function getProcessor() |
|
90 | |||
91 | /** |
||
92 | * Returns a token generator from the adapter factory |
||
93 | * |
||
94 | * @return GeneratorCotnract |
||
95 | */ |
||
96 | 5 | protected function getGenerator() |
|
100 | |||
101 | /** |
||
102 | * Gets the provider |
||
103 | * |
||
104 | * @return UserProvider |
||
105 | */ |
||
106 | 6 | public function getProvider() |
|
110 | |||
111 | /** |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | 1 | public function user() |
|
126 | |||
127 | /** |
||
128 | * Get's the bearer token from the request header |
||
129 | * |
||
130 | * @return Token |
||
131 | */ |
||
132 | 4 | public function getBearerToken() |
|
145 | |||
146 | /** |
||
147 | * @inheritdoc |
||
148 | */ |
||
149 | 2 | public function validate(array $credentials = []) |
|
157 | |||
158 | /** |
||
159 | * Determine if the user matches the credentials. |
||
160 | * |
||
161 | * @param mixed $user |
||
162 | * @param array $credentials |
||
163 | * @return bool |
||
164 | */ |
||
165 | 5 | protected function hasValidCredentials($user, $credentials) |
|
169 | |||
170 | /** |
||
171 | * Sets the Request |
||
172 | * |
||
173 | * @param Request $request |
||
174 | */ |
||
175 | 1 | public function setRequest(Request $request) |
|
179 | |||
180 | /** |
||
181 | * Gets the request |
||
182 | * |
||
183 | * @return Request |
||
184 | */ |
||
185 | 1 | public function getRequest() |
|
189 | |||
190 | /** |
||
191 | * Attempt to authenticate a user using the given credentials. |
||
192 | * |
||
193 | * @param array $credentials |
||
194 | * @return bool|string |
||
195 | */ |
||
196 | 3 | public function attempt(array $credentials = []) |
|
211 | } |
||
212 |