Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
4038b4d1
Commit
4038b4d1
authored
May 26, 2016
by
Mukesh
Committed by
Torkel Ödegaard
May 26, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Set active org through admin api (#5179)
parent
f923edc4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
pkg/api/api.go
+1
-0
pkg/api/user.go
+18
-0
No files found.
pkg/api/api.go
View file @
4038b4d1
...
...
@@ -115,6 +115,7 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/:id"
,
wrap
(
GetUserById
))
r
.
Get
(
"/:id/orgs"
,
wrap
(
GetUserOrgList
))
r
.
Put
(
"/:id"
,
bind
(
m
.
UpdateUserCommand
{}),
wrap
(
UpdateUser
))
r
.
Post
(
"/:id/using/:orgId"
,
wrap
(
UpdateUserActiveOrg
))
},
reqGrafanaAdmin
)
// org information available to all users.
...
...
pkg/api/user.go
View file @
4038b4d1
...
...
@@ -40,6 +40,24 @@ func UpdateUser(c *middleware.Context, cmd m.UpdateUserCommand) Response {
return
handleUpdateUser
(
cmd
)
}
//POST /api/users/:id/using/:orgId
func
UpdateUserActiveOrg
(
c
*
middleware
.
Context
)
Response
{
userId
:=
c
.
ParamsInt64
(
":id"
)
orgId
:=
c
.
ParamsInt64
(
":orgId"
)
if
!
validateUsingOrg
(
userId
,
orgId
)
{
return
ApiError
(
401
,
"Not a valid organization"
,
nil
)
}
cmd
:=
m
.
SetUsingOrgCommand
{
UserId
:
userId
,
OrgId
:
orgId
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
return
ApiError
(
500
,
"Failed change active organization"
,
err
)
}
return
ApiSuccess
(
"Active organization changed"
)
}
func
handleUpdateUser
(
cmd
m
.
UpdateUserCommand
)
Response
{
if
len
(
cmd
.
Login
)
==
0
{
cmd
.
Login
=
cmd
.
Email
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment