mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Identity: remove GetTypedID (#91745)
This commit is contained in:
@@ -31,8 +31,7 @@ import (
|
||||
// 404: notFoundError
|
||||
// 500: internalServerError
|
||||
func (hs *HTTPServer) GetSignedInUser(c *contextmodel.ReqContext) response.Response {
|
||||
namespace, identifier := c.SignedInUser.GetTypedID()
|
||||
if namespace != identity.TypeUser {
|
||||
if !identity.IsIdentityType(c.GetID(), identity.TypeUser) {
|
||||
return response.JSON(http.StatusOK, user.UserProfileDTO{
|
||||
IsGrafanaAdmin: c.SignedInUser.GetIsGrafanaAdmin(),
|
||||
OrgID: c.SignedInUser.GetOrgID(),
|
||||
@@ -43,7 +42,7 @@ func (hs *HTTPServer) GetSignedInUser(c *contextmodel.ReqContext) response.Respo
|
||||
})
|
||||
}
|
||||
|
||||
userID, err := identity.IntIdentifier(namespace, identifier)
|
||||
userID, err := identity.UserIdentifier(c.GetID())
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Failed to parse user id", err)
|
||||
}
|
||||
@@ -278,8 +277,7 @@ func (hs *HTTPServer) handleUpdateUser(ctx context.Context, cmd user.UpdateUserC
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) StartEmailVerificaton(c *contextmodel.ReqContext) response.Response {
|
||||
namespace, id := c.SignedInUser.GetTypedID()
|
||||
if !identity.IsIdentityType(namespace, identity.TypeUser) {
|
||||
if !identity.IsIdentityType(c.SignedInUser.GetID(), identity.TypeUser) {
|
||||
return response.Error(http.StatusBadRequest, "Only users can verify their email", nil)
|
||||
}
|
||||
|
||||
@@ -288,7 +286,7 @@ func (hs *HTTPServer) StartEmailVerificaton(c *contextmodel.ReqContext) response
|
||||
return response.Respond(http.StatusNotModified, nil)
|
||||
}
|
||||
|
||||
userID, err := strconv.ParseInt(id, 10, 64)
|
||||
userID, err := identity.UserIdentifier(c.SignedInUser.GetID())
|
||||
if err != nil {
|
||||
return response.Error(http.StatusInternalServerError, "Got invalid user id", err)
|
||||
}
|
||||
@@ -506,13 +504,12 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *contextmodel.ReqContex
|
||||
return
|
||||
}
|
||||
|
||||
namespace, identifier := c.SignedInUser.GetTypedID()
|
||||
if namespace != identity.TypeUser {
|
||||
if !identity.IsIdentityType(c.SignedInUser.GetID(), identity.TypeUser) {
|
||||
c.JsonApiErr(http.StatusForbidden, "Endpoint only available for users", nil)
|
||||
return
|
||||
}
|
||||
|
||||
userID, err := identity.IntIdentifier(namespace, identifier)
|
||||
userID, err := identity.UserIdentifier(c.SignedInUser.GetID())
|
||||
if err != nil {
|
||||
c.JsonApiErr(http.StatusInternalServerError, "Failed to parse user id", err)
|
||||
return
|
||||
@@ -632,12 +629,11 @@ func (hs *HTTPServer) ClearHelpFlags(c *contextmodel.ReqContext) response.Respon
|
||||
}
|
||||
|
||||
func getUserID(c *contextmodel.ReqContext) (int64, *response.NormalResponse) {
|
||||
namespace, identifier := c.SignedInUser.GetTypedID()
|
||||
if namespace != identity.TypeUser {
|
||||
if !identity.IsIdentityType(c.SignedInUser.GetID(), identity.TypeUser) {
|
||||
return 0, response.Error(http.StatusForbidden, "Endpoint only available for users", nil)
|
||||
}
|
||||
|
||||
userID, err := identity.IntIdentifier(namespace, identifier)
|
||||
userID, err := identity.UserIdentifier(c.SignedInUser.GetID())
|
||||
if err != nil {
|
||||
return 0, response.Error(http.StatusInternalServerError, "Failed to parse user id", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user