Skip to content

Commit

Permalink
Futher shared code
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jul 21, 2022
1 parent 7d1455d commit 077b73d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
5 changes: 0 additions & 5 deletions http/api/tokenpki.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,6 @@ func DecryptTokenPKIHandler(store TokenPKIRetriever, tokenStore AuthTokensStorer
jsonError(w, err)
return
}
if !tokens.Valid() {
logger.Info("msg", "checking auth token validity", "err", "invalid tokens")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
storeTokens(r.Context(), logger, r.URL.Path, tokens, tokenStore, w)
}
}
10 changes: 5 additions & 5 deletions http/api/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ func StoreAuthTokensHandler(store AuthTokensStorer, logger log.Logger) http.Hand
return
}
defer r.Body.Close()
if !tokens.Valid() {
logger.Info("msg", "checking auth token validity", "err", "invalid tokens")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
storeTokens(r.Context(), logger, r.URL.Path, tokens, store, w)
}
}

func storeTokens(ctx context.Context, logger log.Logger, name string, tokens *client.OAuth1Tokens, store AuthTokensStorer, w http.ResponseWriter) {
if !tokens.Valid() {
logger.Info("msg", "checking auth token validity", "err", "invalid tokens")
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return
}
logger = logger.With("consumer_key", tokens.ConsumerKey)
err := store.StoreAuthTokens(ctx, name, tokens)
if err != nil {
Expand Down

0 comments on commit 077b73d

Please sign in to comment.