Chore: Add user service method SetUsingOrg and GetSignedInUserWithCacheCtx (#53343)
* Chore: Add user service method SetUsingOrg * Chore: Add user service method GetSignedInUserWithCacheCtx * Use method GetSignedInUserWithCacheCtx from user service * Fix lint after rebase * Fix lint * Fix lint error * roll back some changes * Roll back changes in api and middleware * Add xorm tags to SignedInUser ID fields
This commit is contained in:
+3
-3
@@ -17,7 +17,7 @@ func (hs *HTTPServer) commentsGet(c *models.ReqContext) response.Response {
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
items, err := hs.commentsService.Get(c.Req.Context(), c.OrgId, c.SignedInUser, cmd)
|
||||
items, err := hs.commentsService.Get(c.Req.Context(), c.OrgID, c.SignedInUser, cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, comments.ErrPermissionDenied) {
|
||||
return response.Error(http.StatusForbidden, "permission denied", err)
|
||||
@@ -34,10 +34,10 @@ func (hs *HTTPServer) commentsCreate(c *models.ReqContext) response.Response {
|
||||
if err := web.Bind(c.Req, &cmd); err != nil {
|
||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||
}
|
||||
if c.SignedInUser.UserId == 0 && !c.SignedInUser.HasRole(org.RoleAdmin) {
|
||||
if c.SignedInUser.UserID == 0 && !c.SignedInUser.HasRole(org.RoleAdmin) {
|
||||
return response.Error(http.StatusForbidden, "admin role required", nil)
|
||||
}
|
||||
comment, err := hs.commentsService.Create(c.Req.Context(), c.OrgId, c.SignedInUser, cmd)
|
||||
comment, err := hs.commentsService.Create(c.Req.Context(), c.OrgID, c.SignedInUser, cmd)
|
||||
if err != nil {
|
||||
if errors.Is(err, comments.ErrPermissionDenied) {
|
||||
return response.Error(http.StatusForbidden, "permission denied", err)
|
||||
|
||||
Reference in New Issue
Block a user