1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-08-01 17:38:37 +00:00

feat(api): add new endpoints to manage API keys

This commit is contained in:
Frédéric Guillot 2025-05-25 15:37:37 -07:00
parent ebd65da3b6
commit bfd8860398
13 changed files with 316 additions and 66 deletions

View file

@ -0,0 +1,22 @@
// SPDX-FileCopyrightText: Copyright The Miniflux Authors. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package validator // import "miniflux.app/v2/internal/validator"
import (
"miniflux.app/v2/internal/locale"
"miniflux.app/v2/internal/model"
"miniflux.app/v2/internal/storage"
)
func ValidateAPIKeyCreation(store *storage.Storage, userID int64, request *model.APIKeyCreationRequest) *locale.LocalizedError {
if request.Description == "" {
return locale.NewLocalizedError("error.fields_mandatory")
}
if store.APIKeyExists(userID, request.Description) {
return locale.NewLocalizedError("error.api_key_already_exists")
}
return nil
}