Browse Source

添加用户角色管理

2023
chenyifan01 2 years ago
parent
commit
c397f131f5
1 changed files with 1 additions and 7 deletions
  1. +1
    -7
      routers/api/v1/tech/tech.go

+ 1
- 7
routers/api/v1/tech/tech.go View File

@@ -254,13 +254,7 @@ func FindTech(ctx *context.APIContext) {
} }


func IsAdmin(ctx *context.APIContext) { func IsAdmin(ctx *context.APIContext) {
userName := ctx.Query("user")
user, err := models.GetUserByName(userName)
if err != nil {
ctx.JSON(http.StatusOK, response.OuterServerError("User not exists"))
return
}
isAdmin := role.UserHasRole(user.ID, models.TechProgramAdmin)
isAdmin := role.UserHasRole(ctx.User.ID, models.TechProgramAdmin)
r := map[string]interface{}{} r := map[string]interface{}{}
r["is_admin"] = isAdmin r["is_admin"] = isAdmin
ctx.JSON(http.StatusOK, response.OuterSuccessWithData(r)) ctx.JSON(http.StatusOK, response.OuterSuccessWithData(r))


Loading…
Cancel
Save