Skip to content
Permalink
Browse files

Handle errors from setting cookie

  • Loading branch information...
biilmann committed Sep 29, 2017
1 parent b48d5fe commit 77973228ce169a4e10fd0e52fd1bc1357d930096
Showing with 9 additions and 3 deletions.
  1. +6 −2 api/token.go
  2. +3 −1 api/verify.go
@@ -69,7 +69,9 @@ func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWri
}

if cookie != "" && config.Cookie.Enabled {
a.setCookieToken(ctx, user, cookie == useSessionCookie, w)
if err = a.setCookieToken(ctx, user, cookie == useSessionCookie, w); err != nil {
return internalServerError("Failed to set JWT cookie", err)
}
}

return a.sendRefreshToken(ctx, user, w)
@@ -109,7 +111,9 @@ func (a *API) RefreshTokenGrant(ctx context.Context, w http.ResponseWriter, r *h
}

if cookie != "" && config.Cookie.Enabled {
a.setCookieToken(ctx, user, cookie == useSessionCookie, w)
if err = a.setCookieToken(ctx, user, cookie == useSessionCookie, w); err != nil {
return internalServerError("Failed to set JWT cookie", err)
}
}

return sendJSON(w, http.StatusOK, &AccessTokenResponse{
@@ -54,7 +54,9 @@ func (a *API) Verify(w http.ResponseWriter, r *http.Request) error {
}

if cookie != "" && config.Cookie.Enabled {
a.setCookieToken(ctx, user, cookie == useSessionCookie, w)
if err = a.setCookieToken(ctx, user, cookie == useSessionCookie, w); err != nil {
return internalServerError("Failed to set JWT cookie", err)
}
}

return a.sendRefreshToken(ctx, user, w)

0 comments on commit 7797322

Please sign in to comment.
You can’t perform that action at this time.