IAM: remove duplicated functions (#96989)

* Remove duplicated function and use the one provided by claims package
This commit is contained in:
Karl Persson
2024-11-26 09:22:45 +01:00
committed by GitHub
parent 3dbd3a7a81
commit 3990637af9
20 changed files with 37 additions and 74 deletions
+3 -3
View File
@@ -11,7 +11,6 @@ import (
"github.com/grafana/authlib/claims"
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/apimachinery/identity"
"github.com/grafana/grafana/pkg/infra/metrics"
"github.com/grafana/grafana/pkg/services/accesscontrol"
"github.com/grafana/grafana/pkg/services/auth"
@@ -363,12 +362,13 @@ func (hs *HTTPServer) AdminEnableUser(c *contextmodel.ReqContext) response.Respo
// 404: notFoundError
// 500: internalServerError
func (hs *HTTPServer) AdminLogoutUser(c *contextmodel.ReqContext) response.Response {
userID, err := strconv.ParseInt(web.Params(c.Req)[":id"], 10, 64)
id := web.Params(c.Req)[":id"]
userID, err := strconv.ParseInt(id, 10, 64)
if err != nil {
return response.Error(http.StatusBadRequest, "id is invalid", err)
}
if c.SignedInUser.GetID() == identity.NewTypedID(claims.TypeUser, userID) {
if c.SignedInUser.GetID() == claims.NewTypeID(claims.TypeUser, id) {
return response.Error(http.StatusBadRequest, "You cannot logout yourself", nil)
}