mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
pkg/util: Check errors (#19832)
* pkg/util: Check errors * pkg/services: DRY up code
This commit is contained in:
@@ -128,7 +128,12 @@ func initContextWithApiKey(ctx *models.ReqContext) bool {
|
||||
apikey := keyQuery.Result
|
||||
|
||||
// validate api key
|
||||
if !apikeygen.IsValid(decoded, apikey.Key) {
|
||||
isValid, err := apikeygen.IsValid(decoded, apikey.Key)
|
||||
if err != nil {
|
||||
ctx.JsonApiErr(500, "Validating API key failed", err)
|
||||
return true
|
||||
}
|
||||
if !isValid {
|
||||
ctx.JsonApiErr(401, errStringInvalidAPIKey, err)
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user