Service Accounts: Don't show error pop-ups for Service Account and Renderer UI flows (#101679)
don't show error pop-ups for SAs and renderer
This commit is contained in:
+10
-8
@@ -149,7 +149,7 @@ func (hs *HTTPServer) UpdateSignedInUser(c *contextmodel.ReqContext) response.Re
|
|||||||
cmd.Email = strings.TrimSpace(cmd.Email)
|
cmd.Email = strings.TrimSpace(cmd.Email)
|
||||||
cmd.Login = strings.TrimSpace(cmd.Login)
|
cmd.Login = strings.TrimSpace(cmd.Login)
|
||||||
|
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -349,7 +349,7 @@ func (hs *HTTPServer) UpdateUserEmail(c *contextmodel.ReqContext) response.Respo
|
|||||||
// 403: forbiddenError
|
// 403: forbiddenError
|
||||||
// 500: internalServerError
|
// 500: internalServerError
|
||||||
func (hs *HTTPServer) GetSignedInUserOrgList(c *contextmodel.ReqContext) response.Response {
|
func (hs *HTTPServer) GetSignedInUserOrgList(c *contextmodel.ReqContext) response.Response {
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -369,7 +369,7 @@ func (hs *HTTPServer) GetSignedInUserOrgList(c *contextmodel.ReqContext) respons
|
|||||||
// 403: forbiddenError
|
// 403: forbiddenError
|
||||||
// 500: internalServerError
|
// 500: internalServerError
|
||||||
func (hs *HTTPServer) GetSignedInUserTeamList(c *contextmodel.ReqContext) response.Response {
|
func (hs *HTTPServer) GetSignedInUserTeamList(c *contextmodel.ReqContext) response.Response {
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -479,7 +479,7 @@ func (hs *HTTPServer) UserSetUsingOrg(c *contextmodel.ReqContext) response.Respo
|
|||||||
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -504,6 +504,7 @@ func (hs *HTTPServer) ChangeActiveOrgAndRedirectToHome(c *contextmodel.ReqContex
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.SignedInUser.IsIdentityType(claims.TypeUser) {
|
if !c.SignedInUser.IsIdentityType(claims.TypeUser) {
|
||||||
|
hs.log.Debug("Requested endpoint only available to users")
|
||||||
c.JsonApiErr(http.StatusForbidden, "Endpoint only available for users", nil)
|
c.JsonApiErr(http.StatusForbidden, "Endpoint only available for users", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -548,7 +549,7 @@ func (hs *HTTPServer) ChangeUserPassword(c *contextmodel.ReqContext) response.Re
|
|||||||
return response.Error(http.StatusBadRequest, "bad request data", err)
|
return response.Error(http.StatusBadRequest, "bad request data", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -584,7 +585,7 @@ func (hs *HTTPServer) SetHelpFlag(c *contextmodel.ReqContext) response.Response
|
|||||||
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
return response.Error(http.StatusBadRequest, "id is invalid", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -614,7 +615,7 @@ func (hs *HTTPServer) SetHelpFlag(c *contextmodel.ReqContext) response.Response
|
|||||||
// 403: forbiddenError
|
// 403: forbiddenError
|
||||||
// 500: internalServerError
|
// 500: internalServerError
|
||||||
func (hs *HTTPServer) ClearHelpFlags(c *contextmodel.ReqContext) response.Response {
|
func (hs *HTTPServer) ClearHelpFlags(c *contextmodel.ReqContext) response.Response {
|
||||||
userID, errResponse := getUserID(c)
|
userID, errResponse := hs.getUserID(c)
|
||||||
if errResponse != nil {
|
if errResponse != nil {
|
||||||
return errResponse
|
return errResponse
|
||||||
}
|
}
|
||||||
@@ -627,8 +628,9 @@ func (hs *HTTPServer) ClearHelpFlags(c *contextmodel.ReqContext) response.Respon
|
|||||||
return response.JSON(http.StatusOK, &util.DynMap{"message": "Help flag set", "helpFlags1": flags})
|
return response.JSON(http.StatusOK, &util.DynMap{"message": "Help flag set", "helpFlags1": flags})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getUserID(c *contextmodel.ReqContext) (int64, *response.NormalResponse) {
|
func (hs *HTTPServer) getUserID(c *contextmodel.ReqContext) (int64, *response.NormalResponse) {
|
||||||
if !c.SignedInUser.IsIdentityType(claims.TypeUser) {
|
if !c.SignedInUser.IsIdentityType(claims.TypeUser) {
|
||||||
|
hs.log.Debug("Requested endpoint only available to users")
|
||||||
return 0, response.Error(http.StatusForbidden, "Endpoint only available for users", nil)
|
return 0, response.Error(http.StatusForbidden, "Endpoint only available for users", nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,6 +347,15 @@ export class BackendSrv implements BackendService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showErrorAlert(config: BackendSrvRequest, err: FetchError) {
|
showErrorAlert(config: BackendSrvRequest, err: FetchError) {
|
||||||
|
// do not show error alerts for api keys or render tokens, they are used for kiosk mode and reporting and can't react to error pop-ups
|
||||||
|
if (
|
||||||
|
this.dependencies.contextSrv.isSignedIn &&
|
||||||
|
(this.dependencies.contextSrv.user.authenticatedBy === 'apikey' ||
|
||||||
|
this.dependencies.contextSrv.user.authenticatedBy === 'render')
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.showErrorAlert === false) {
|
if (config.showErrorAlert === false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user