fix: redirect to login upon authentication error (#9134)

This commit is contained in:
Kayla Washburn
2023-08-17 13:54:20 -06:00
committed by GitHub
parent 720ad9a653
commit 9710bada06
4 changed files with 47 additions and 4 deletions

View File

@ -308,6 +308,9 @@ func ExtractAPIKey(rw http.ResponseWriter, r *http.Request, cfg ExtractAPIKeyCon
}
// Checking if the key is expired.
// NOTE: The `RequireAuth` React component depends on this `Detail` to detect when
// the users token has expired. If you change the text here, make sure to update it
// in site/src/components/RequireAuth/RequireAuth.tsx as well.
if key.ExpiresAt.Before(now) {
return optionalWrite(http.StatusUnauthorized, codersdk.Response{
Message: SignedOutErrorMessage,