File tree Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Expand file tree Collapse file tree 3 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ func Register(r *macaron.Macaron) {
30
30
// authed views
31
31
r .Get ("/profile/" , reqSignedIn , Index )
32
32
r .Get ("/profile/password" , reqSignedIn , Index )
33
+ r .Get ("/profile/switch-org/:id" , reqSignedIn , ChangeActiveOrgAndRedirectToHome )
33
34
r .Get ("/org/" , reqSignedIn , Index )
34
35
r .Get ("/org/new" , reqSignedIn , Index )
35
36
r .Get ("/datasources/" , reqSignedIn , Index )
Original file line number Diff line number Diff line change 4
4
"github.com/grafana/grafana/pkg/bus"
5
5
"github.com/grafana/grafana/pkg/middleware"
6
6
m "github.com/grafana/grafana/pkg/models"
7
+ "github.com/grafana/grafana/pkg/setting"
7
8
"github.com/grafana/grafana/pkg/util"
8
9
)
9
10
@@ -109,6 +110,23 @@ func UserSetUsingOrg(c *middleware.Context) Response {
109
110
return ApiSuccess ("Active organization changed" )
110
111
}
111
112
113
+ // GET /profile/switch-org/:id
114
+ func ChangeActiveOrgAndRedirectToHome (c * middleware.Context ) {
115
+ orgId := c .ParamsInt64 (":id" )
116
+
117
+ if ! validateUsingOrg (c .UserId , orgId ) {
118
+ NotFoundHandler (c )
119
+ }
120
+
121
+ cmd := m.SetUsingOrgCommand {UserId : c .UserId , OrgId : orgId }
122
+
123
+ if err := bus .Dispatch (& cmd ); err != nil {
124
+ NotFoundHandler (c )
125
+ }
126
+
127
+ c .Redirect (setting .AppSubUrl + "/" )
128
+ }
129
+
112
130
func ChangeUserPassword (c * middleware.Context , cmd m.ChangeUserPasswordCommand ) Response {
113
131
userQuery := m.GetUserByIdQuery {Id : c .UserId }
114
132
Original file line number Diff line number Diff line change @@ -72,9 +72,8 @@ export class SideMenuCtrl {
72
72
this . orgMenu . push ( {
73
73
text : "Switch to " + org . name ,
74
74
icon : "fa fa-fw fa-random" ,
75
- click : ( ) => {
76
- this . switchOrg ( org . orgId ) ;
77
- }
75
+ url : this . getUrl ( '/profile/switch-org/' + org . orgId ) ,
76
+ target : '_self'
78
77
} ) ;
79
78
} ) ;
80
79
You can’t perform that action at this time.
0 commit comments