add api: check perm

This commit is contained in:
UlricQin 2021-12-05 20:40:13 +08:00
parent 022fef2b9e
commit df97166f07
2 changed files with 9 additions and 0 deletions

View File

@ -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)

View File

@ -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) {