Ejemplo n.º 1
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     $response = $next($request);
     if ($this->shouldReceiveFreshToken($request, $response)) {
         $response->withCookie($this->tokens->createTokenCookie($request->user()));
     }
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * Get the token instance from the database.
  *
  * @param  Request  $request
  * @return Token
  */
 protected function getToken(Request $request)
 {
     $token = $this->getTokenFromRequest($request);
     if ($token instanceof Token) {
         return $token;
     } else {
         return $token ? $this->tokens->validToken($token) : null;
     }
 }
Ejemplo n.º 3
0
 /**
  * Exchange the current transient API token for a new one.
  *
  * @return Response
  */
 public function refresh(Request $request)
 {
     $this->tokens->deleteExpiredTokens($request->user());
     return response('Refreshed.')->withCookie($this->tokens->createTokenCookie($request->user()));
 }
Ejemplo n.º 4
0
 /**
  * Update the given API token.
  *
  * @param  UpdateTokenRequest  $request
  * @param  string  $tokenId
  * @return Response
  */
 public function update(UpdateTokenRequest $request, $tokenId)
 {
     $token = $request->user()->tokens()->where('id', $tokenId)->firstOrFail();
     $this->tokens->updateToken($token, $request->name, (array) $request->abilities);
 }