| Conditions | 4 |
| Paths | 6 |
| Total Lines | 19 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function handle(Request $request, Closure $next) |
||
| 22 | { |
||
| 23 | if ($this->isAccessCodeValid($request->route('token'), $request->get('magic.link-access-code'))) { |
||
|
|
|||
| 24 | // access code is valid |
||
| 25 | setcookie('magic.link-access-code', encrypt($request->get('magic.link-access-code')), 0, '/'); |
||
| 26 | return redirect($request->url()); |
||
| 27 | } |
||
| 28 | |||
| 29 | try { |
||
| 30 | $accessCode = decrypt(Arr::get($_COOKIE, 'magic.link-access-code')); |
||
| 31 | // Validate access_code |
||
| 32 | if ($this->isAccessCodeValid($request->route('token'), $accessCode)) { |
||
| 33 | return $next($request); |
||
| 34 | } |
||
| 35 | } catch (DecryptException $e) { |
||
| 36 | // empty value in cookie |
||
| 37 | } |
||
| 38 | |||
| 39 | return response(view('magiclink::ask-for-access-code-form'), 403); |
||
| 40 | } |
||
| 53 |