add api: check perm
This commit is contained in:
parent
022fef2b9e
commit
df97166f07
|
@ -137,6 +137,7 @@ func configRoute(r *gin.Engine, version string) {
|
|||
pages.DELETE("/user-group/:id", jwtAuth(), user(), userGroupWrite(), userGroupDel)
|
||||
pages.POST("/user-group/:id/members", jwtAuth(), user(), userGroupWrite(), userGroupMemberAdd)
|
||||
pages.DELETE("/user-group/:id/members", jwtAuth(), user(), userGroupWrite(), userGroupMemberDel)
|
||||
pages.GET("/user-group/:id/perm/:perm", jwtAuth(), user(), checkBusiGroupPerm)
|
||||
|
||||
pages.POST("/busi-groups", jwtAuth(), user(), busiGroupAdd)
|
||||
pages.GET("/busi-groups", jwtAuth(), user(), busiGroupGets)
|
||||
|
|
|
@ -10,6 +10,14 @@ import (
|
|||
"github.com/didi/nightingale/v5/src/models"
|
||||
)
|
||||
|
||||
func checkBusiGroupPerm(c *gin.Context) {
|
||||
me := c.MustGet("user").(*models.User)
|
||||
bg := BusiGroup(ginx.UrlParamInt64(c, "id"))
|
||||
|
||||
can, err := me.CanDoBusiGroup(bg, ginx.UrlParamStr(c, "perm"))
|
||||
ginx.NewRender(c).Data(can, err)
|
||||
}
|
||||
|
||||
// Return all, front-end search and paging
|
||||
// I'm creator or member
|
||||
func userGroupGets(c *gin.Context) {
|
||||
|
|
Loading…
Reference in New Issue