1
0
mirror of https://github.com/pocket-id/pocket-id.git synced 2026-03-22 22:00:08 +00:00

fix: disallow API key renewal and creation with API key authentication (#1334)

This commit is contained in:
Elias Schneider
2026-02-23 20:34:25 +01:00
committed by GitHub
parent b3fe143136
commit 0c41872cd4
5 changed files with 146 additions and 5 deletions

View File

@@ -77,6 +77,9 @@ func (s *ApiKeyService) CreateApiKey(ctx context.Context, userID string, input d
Create(&apiKey).
Error
if err != nil {
if errors.Is(err, gorm.ErrDuplicatedKey) {
return model.ApiKey{}, "", &common.AlreadyInUseError{Property: "API key name"}
}
return model.ApiKey{}, "", err
}