Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8dcd958

Browse files
committed
change language to use sign-out
1 parent fbd0c6d commit 8dcd958

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

coderd/httpmw/apikey.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ type OAuth2Configs struct {
5151
Github OAuth2Config
5252
}
5353

54-
const loggedOutErrorMessage string = "You are logged out. Please log in to continue."
54+
const signedOutErrorMessage string = "You are signed out. Please sign in to continue."
5555

5656
// ExtractAPIKey requires authentication using a valid API key.
5757
// It handles extending an API key if it comes close to expiry,
@@ -85,7 +85,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
8585
}
8686
if cookieValue == "" {
8787
write(http.StatusUnauthorized, codersdk.Response{
88-
Message: loggedOutErrorMessage,
88+
Message: signedOutErrorMessage,
8989
Detail: fmt.Sprintf("Cookie %q or query parameter must be provided.", codersdk.SessionTokenKey),
9090
})
9191
return
@@ -94,7 +94,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
9494
// APIKeys are formatted: ID-SECRET
9595
if len(parts) != 2 {
9696
write(http.StatusUnauthorized, codersdk.Response{
97-
Message: loggedOutErrorMessage,
97+
Message: signedOutErrorMessage,
9898
Detail: fmt.Sprintf("Invalid %q cookie API key format.", codersdk.SessionTokenKey),
9999
})
100100
return
@@ -104,14 +104,14 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
104104
// Ensuring key lengths are valid.
105105
if len(keyID) != 10 {
106106
write(http.StatusUnauthorized, codersdk.Response{
107-
Message: loggedOutErrorMessage,
107+
Message: signedOutErrorMessage,
108108
Detail: fmt.Sprintf("Invalid %q cookie API key id.", codersdk.SessionTokenKey),
109109
})
110110
return
111111
}
112112
if len(keySecret) != 22 {
113113
write(http.StatusUnauthorized, codersdk.Response{
114-
Message: loggedOutErrorMessage,
114+
Message: signedOutErrorMessage,
115115
Detail: fmt.Sprintf("Invalid %q cookie API key secret.", codersdk.SessionTokenKey),
116116
})
117117
return
@@ -120,7 +120,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
120120
if err != nil {
121121
if errors.Is(err, sql.ErrNoRows) {
122122
write(http.StatusUnauthorized, codersdk.Response{
123-
Message: loggedOutErrorMessage,
123+
Message: signedOutErrorMessage,
124124
Detail: "API key is invalid.",
125125
})
126126
return
@@ -136,7 +136,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
136136
// Checking to see if the secret is valid.
137137
if subtle.ConstantTimeCompare(key.HashedSecret, hashed[:]) != 1 {
138138
write(http.StatusUnauthorized, codersdk.Response{
139-
Message: loggedOutErrorMessage,
139+
Message: signedOutErrorMessage,
140140
Detail: "API key secret is invalid.",
141141
})
142142
return
@@ -182,7 +182,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
182182
// Checking if the key is expired.
183183
if key.ExpiresAt.Before(now) {
184184
write(http.StatusUnauthorized, codersdk.Response{
185-
Message: loggedOutErrorMessage,
185+
Message: signedOutErrorMessage,
186186
Detail: fmt.Sprintf("API key expired at %q.", key.ExpiresAt.String()),
187187
})
188188
return
@@ -225,7 +225,7 @@ func ExtractAPIKey(db database.Store, oauth *OAuth2Configs, redirectToLogin bool
225225
})
226226
if err != nil {
227227
write(http.StatusInternalServerError, codersdk.Response{
228-
Message: loggedOutErrorMessage,
228+
Message: signedOutErrorMessage,
229229
Detail: fmt.Sprintf("API key couldn't update: %s.", err.Error()),
230230
})
231231
return

0 commit comments

Comments
 (0)