mirror of
https://github.com/anyproto/anytype-heart.git
synced 2025-06-08 05:47:07 +09:00
GO-5589: Update invalid token error to api key terminology
This commit is contained in:
parent
cbf881c589
commit
2f96ac3f63
2 changed files with 3 additions and 3 deletions
|
@ -24,7 +24,7 @@ var log = logging.Logger("api-server")
|
|||
var (
|
||||
ErrMissingAuthorizationHeader = errors.New("missing authorization header")
|
||||
ErrInvalidAuthorizationHeader = errors.New("invalid authorization header format")
|
||||
ErrInvalidToken = errors.New("invalid token")
|
||||
ErrInvalidApiKey = errors.New("invalid api key")
|
||||
)
|
||||
|
||||
// ensureRateLimit creates a shared write-rate limiter middleware.
|
||||
|
@ -76,7 +76,7 @@ func (s *Server) ensureAuthenticated(mw apicore.ClientCommands) gin.HandlerFunc
|
|||
if !exists {
|
||||
response := mw.WalletCreateSession(context.Background(), &pb.RpcWalletCreateSessionRequest{Auth: &pb.RpcWalletCreateSessionRequestAuthOfAppKey{AppKey: key}})
|
||||
if response.Error.Code != pb.RpcWalletCreateSessionResponseError_NULL {
|
||||
apiErr := util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidToken.Error())
|
||||
apiErr := util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidApiKey.Error())
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, apiErr)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestEnsureAuthenticated(t *testing.T) {
|
|||
|
||||
// then
|
||||
require.Equal(t, http.StatusUnauthorized, w.Code)
|
||||
expectedJSON, err := json.Marshal(util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidToken.Error()))
|
||||
expectedJSON, err := json.Marshal(util.CodeToAPIError(http.StatusUnauthorized, ErrInvalidApiKey.Error()))
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, string(expectedJSON), w.Body.String())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue