1 | <?php |
||
20 | class JWTGuard implements Guard |
||
21 | { |
||
22 | use GuardHelpers; |
||
23 | |||
24 | /** |
||
25 | * The user we last attempted to retrieve. |
||
26 | * |
||
27 | * @var \Illuminate\Contracts\Auth\Authenticatable |
||
28 | */ |
||
29 | protected $lastAttempted; |
||
30 | |||
31 | /** |
||
32 | * The JWTAuth instance. |
||
33 | * |
||
34 | * @var \Tymon\JWTAuth\JWTAuth |
||
35 | */ |
||
36 | protected $auth; |
||
37 | |||
38 | /** |
||
39 | * The request instance. |
||
40 | * |
||
41 | * @var \Illuminate\Http\Request |
||
42 | */ |
||
43 | protected $request; |
||
44 | |||
45 | public function __construct(JWTAuth $auth, UserProvider $provider, Request $request) |
||
51 | |||
52 | /** |
||
53 | * Get the currently authenticated user. |
||
54 | * |
||
55 | * @return \Illuminate\Contracts\Auth\Authenticatable|null |
||
56 | */ |
||
57 | public function user() |
||
71 | |||
72 | /** |
||
73 | * Validate a user's credentials. |
||
74 | * |
||
75 | * @param array $credentials |
||
76 | * |
||
77 | * @return boolean |
||
78 | */ |
||
79 | public function validate(array $credentials = [], $login = true) |
||
96 | |||
97 | /** |
||
98 | * Logout the user, thus invalidating the token. |
||
99 | * |
||
100 | * @param boolean $forceForever |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | public function logout($forceForever = false) |
||
111 | |||
112 | /** |
||
113 | * Get the user provider used by the guard. |
||
114 | * |
||
115 | * @return \Illuminate\Contracts\Auth\UserProvider |
||
116 | */ |
||
117 | public function getProvider() |
||
121 | |||
122 | /** |
||
123 | * Set the user provider used by the guard. |
||
124 | * |
||
125 | * @param \Illuminate\Contracts\Auth\UserProvider $provider |
||
126 | * |
||
127 | * @return void |
||
128 | */ |
||
129 | public function setProvider(UserProvider $provider) |
||
133 | |||
134 | /** |
||
135 | * Return the currently cached user. |
||
136 | * |
||
137 | * @return \Illuminate\Contracts\Auth\Authenticatable|null |
||
138 | */ |
||
139 | public function getUser() |
||
143 | |||
144 | /** |
||
145 | * Get the current request instance. |
||
146 | * |
||
147 | * @return \Symfony\Component\HttpFoundation\Request |
||
148 | */ |
||
149 | public function getRequest() |
||
153 | |||
154 | /** |
||
155 | * Set the current request instance. |
||
156 | * |
||
157 | * @param \Symfony\Component\HttpFoundation\Request $request |
||
158 | * |
||
159 | * @return $this |
||
160 | */ |
||
161 | public function setRequest(Request $request) |
||
167 | |||
168 | /** |
||
169 | * Get the last user we attempted to authenticate. |
||
170 | * |
||
171 | * @return \Illuminate\Contracts\Auth\Authenticatable |
||
172 | */ |
||
173 | public function getLastAttempted() |
||
177 | |||
178 | /** |
||
179 | * Determine if the user matches the credentials. |
||
180 | * |
||
181 | * @param mixed $user |
||
182 | * @param array $credentials |
||
183 | * |
||
184 | * @return boolean |
||
185 | */ |
||
186 | protected function hasValidCredentials($user, $credentials) |
||
190 | |||
191 | /** |
||
192 | * Ensure that a token is available in the request |
||
193 | * |
||
194 | * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException |
||
195 | * |
||
196 | * @return \Tymon\JWTAuth\JWTAuth |
||
197 | */ |
||
198 | protected function requireToken() |
||
206 | } |
||
207 |