Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
487 B
0
Indexable
Never
  public function handle(Request $request, Closure $next)
  {
    info($request->bearerToken());

    $cookie_name = 'NocturnaCookie';
    if (!$request->bearerToken()) {
      if ($request->hasCookie($cookie_name)) {
        $token = $request->cookie($cookie_name);
        $request->headers->add([
          'Authorization' => 'Bearer ' . $token
        ]);
      }
    }

    if ($request->user()) {
      return $next($request);
    }

    return response('Unauthorised', 401);
  }
}
Leave a Comment