Example #1
0
 /**
  * Get the token for the given request cookie.
  *
  * @param  Request  $request
  * @return Token
  */
 protected function getTokenFromCookie($request)
 {
     // If we need to retrieve the token from the cookie, it'll be encrypted so we must
     // first decrypt the cookie and then attempt to find the token value within the
     // database. If we can't decrypt the value we'll bail out with a null return.
     try {
         $token = JWT::decode($request->cookie('kodicms_token'));
     } catch (Exception $e) {
         return;
     }
     return $this->tokens->valid($token['token']);
 }
 /**
  * @param Token $token
  *
  * @return \Symfony\Component\HttpFoundation\Cookie
  */
 public function createCookie(Token $token)
 {
     $token = JWT::encode(['token' => $token->id, 'expiry' => Carbon::now()->addMinutes(5)->getTimestamp()]);
     return cookie('kodicms_token', $token, 5, null, config('session.domain'), config('session.secure'), true);
 }