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
23231e6d
Commit
23231e6d
authored
Mar 11, 2019
by
Leonard Gram
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
teams: added delete team guard
parent
8e7a8282
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
pkg/api/api.go
+1
-1
pkg/api/team.go
+12
-4
No files found.
pkg/api/api.go
View file @
23231e6d
...
...
@@ -155,7 +155,7 @@ func (hs *HTTPServer) registerRoutes() {
// team (admin permission required)
apiRoute
.
Group
(
"/teams"
,
func
(
teamsRoute
routing
.
RouteRegister
)
{
teamsRoute
.
Post
(
"/"
,
bind
(
m
.
CreateTeamCommand
{}),
Wrap
(
hs
.
CreateTeam
))
teamsRoute
.
Put
(
"/:teamId"
,
bind
(
m
.
UpdateTeamCommand
{}),
Wrap
(
hs
.
UpdateTeam
))
teamsRoute
.
Put
(
"/:teamId"
,
bind
(
m
.
UpdateTeamCommand
{}),
Wrap
(
UpdateTeam
))
teamsRoute
.
Delete
(
"/:teamId"
,
Wrap
(
DeleteTeamByID
))
teamsRoute
.
Get
(
"/:teamId/members"
,
Wrap
(
GetTeamMembers
))
teamsRoute
.
Post
(
"/:teamId/members"
,
bind
(
m
.
AddTeamMemberCommand
{}),
Wrap
(
AddTeamMember
))
...
...
pkg/api/team.go
View file @
23231e6d
...
...
@@ -38,12 +38,12 @@ func (hs *HTTPServer) CreateTeam(c *m.ReqContext, cmd m.CreateTeamCommand) Respo
}
// PUT /api/teams/:teamId
func
(
hs
*
HTTPServer
)
UpdateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
UpdateTeamCommand
)
Response
{
func
UpdateTeam
(
c
*
m
.
ReqContext
,
cmd
m
.
UpdateTeamCommand
)
Response
{
cmd
.
OrgId
=
c
.
OrgId
cmd
.
Id
=
c
.
ParamsInt64
(
":teamId"
)
if
err
:=
teams
.
CanUpdateTeam
(
cmd
.
OrgId
,
cmd
.
Id
,
c
.
SignedInUser
);
err
!=
nil
{
return
Error
(
403
,
"
User n
ot allowed to update team"
,
err
)
return
Error
(
403
,
"
N
ot allowed to update team"
,
err
)
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
...
...
@@ -58,11 +58,19 @@ func (hs *HTTPServer) UpdateTeam(c *m.ReqContext, cmd m.UpdateTeamCommand) Respo
// DELETE /api/teams/:teamId
func
DeleteTeamByID
(
c
*
m
.
ReqContext
)
Response
{
if
err
:=
bus
.
Dispatch
(
&
m
.
DeleteTeamCommand
{
OrgId
:
c
.
OrgId
,
Id
:
c
.
ParamsInt64
(
":teamId"
)});
err
!=
nil
{
orgId
:=
c
.
OrgId
teamId
:=
c
.
ParamsInt64
(
":teamId"
)
user
:=
c
.
SignedInUser
if
err
:=
teams
.
CanUpdateTeam
(
orgId
,
teamId
,
user
);
err
!=
nil
{
return
Error
(
403
,
"Not allowed to delete team"
,
err
)
}
if
err
:=
bus
.
Dispatch
(
&
m
.
DeleteTeamCommand
{
OrgId
:
orgId
,
Id
:
teamId
});
err
!=
nil
{
if
err
==
m
.
ErrTeamNotFound
{
return
Error
(
404
,
"Failed to delete Team. ID not found"
,
nil
)
}
return
Error
(
500
,
"Failed to
upda
te Team"
,
err
)
return
Error
(
500
,
"Failed to
dele
te Team"
,
err
)
}
return
Success
(
"Team deleted"
)
}
...
...
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