| Conditions | 5 |
| Paths | 12 |
| Total Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | public function handle($request, Closure $next) |
||
| 11 | { |
||
| 12 | |||
| 13 | if (! $request->hasValidSignature()) { |
||
| 14 | abort(401, 'The welcome link does not have a valid signature or is expired.'); |
||
| 15 | } |
||
| 16 | |||
| 17 | if (! $request->user) { |
||
| 18 | abort(401, 'Could not find a user to be welcomed.'); |
||
| 19 | } |
||
| 20 | |||
| 21 | if (is_null($request->user->welcome_valid_until)) { |
||
| 22 | return abort(401, 'The welcome link has already been used.'); |
||
| 23 | } |
||
| 24 | //dd(Carbon::createFromTimestamp($request->user->welcome_valid_until), $request->user->welcome_valid_until); |
||
| 25 | if (Carbon::create($request->user->welcome_valid_until)->isPast()) { |
||
| 26 | return abort(401, 'The welcome link has expired.'); |
||
| 27 | } |
||
| 28 | |||
| 29 | return $next($request); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |