Identity: remove GetTypedID (#91745)

This commit is contained in:
Karl Persson
2024-08-09 18:20:24 +03:00
committed by GitHub
parent 6061fdc8b9
commit bcfb66b416
47 changed files with 211 additions and 386 deletions
+5 -7
View File
@@ -32,12 +32,11 @@ import (
// 403: forbiddenError
// 500: internalServerError
func (hs *HTTPServer) GetUserAuthTokens(c *contextmodel.ReqContext) response.Response {
namespace, identifier := c.SignedInUser.GetTypedID()
if namespace != identity.TypeUser {
return response.Error(http.StatusForbidden, "entity not allowed to revoke tokens", nil)
if !identity.IsIdentityType(c.SignedInUser.GetID(), identity.TypeUser) {
return response.Error(http.StatusForbidden, "entity not allowed to get tokens", nil)
}
userID, err := identity.IntIdentifier(namespace, identifier)
userID, err := identity.UserIdentifier(c.SignedInUser.GetID())
if err != nil {
return response.Error(http.StatusInternalServerError, "failed to parse user id", err)
}
@@ -63,12 +62,11 @@ func (hs *HTTPServer) RevokeUserAuthToken(c *contextmodel.ReqContext) response.R
return response.Error(http.StatusBadRequest, "bad request data", err)
}
namespace, identifier := c.SignedInUser.GetTypedID()
if namespace != identity.TypeUser {
if !identity.IsIdentityType(c.SignedInUser.GetID(), identity.TypeUser) {
return response.Error(http.StatusForbidden, "entity not allowed to revoke tokens", nil)
}
userID, err := identity.IntIdentifier(namespace, identifier)
userID, err := identity.UserIdentifier(c.SignedInUser.GetID())
if err != nil {
return response.Error(http.StatusInternalServerError, "failed to parse user id", err)
}