User: support setting org and help flags though update function (#86535)

* User: Support setting active org through update function

* User: add support to update help flags through update function
This commit is contained in:
Karl Persson
2024-04-29 08:53:05 +02:00
committed by GitHub
parent 7077a5850e
commit c4cfee8d96
14 changed files with 179 additions and 373 deletions
+1 -2
View File
@@ -32,8 +32,7 @@ func OrgRedirect(cfg *setting.Cfg, userSvc user.Service) web.Handler {
return
}
cmd := user.SetUsingOrgCommand{UserID: ctx.UserID, OrgID: orgId}
if err := userSvc.SetUsingOrg(ctx.Req.Context(), &cmd); err != nil {
if err := userSvc.Update(ctx.Req.Context(), &user.UpdateUserCommand{UserID: ctx.UserID, OrgID: &orgId}); err != nil {
if ctx.IsApiRequest() {
ctx.JsonApiErr(404, "Not found", nil)
} else {
+1 -1
View File
@@ -55,7 +55,7 @@ func TestOrgRedirectMiddleware(t *testing.T) {
middlewareScenario(t, "when setting an invalid org for user", func(t *testing.T, sc *scenarioContext) {
sc.withIdentity(&authn.Identity{})
sc.userService.ExpectedSetUsingOrgError = fmt.Errorf("")
sc.userService.ExpectedError = fmt.Errorf("")
sc.m.Get("/", sc.defaultHandler)
sc.fakeReq("GET", "/?orgId=1").exec()