Skip to content

Commit

Permalink
Merge pull request #282 from actiontech/fix_op_permission
Browse files Browse the repository at this point in the history
Fix op permission
  • Loading branch information
ColdWaterLW authored Jul 17, 2024
2 parents 4a5fbad + 9b4486d commit 4982d48
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -4391,6 +4391,12 @@
"in": "path",
"required": true
},
{
"type": "string",
"x-go-name": "ProjectUid",
"name": "project_uid",
"in": "query"
},
{
"x-go-name": "UserOpPermission",
"description": "user op permission info",
Expand Down
4 changes: 4 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7446,6 +7446,10 @@ paths:
required: true
type: string
x-go-name: UserUid
- in: query
name: project_uid
type: string
x-go-name: ProjectUid
- description: user op permission info
in: body
name: user_op_permission
Expand Down
10 changes: 8 additions & 2 deletions internal/dms/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,18 @@ func (d *DMSService) ListUserGroups(ctx context.Context, req *dmsV1.ListUserGrou
}

func (d *DMSService) GetUserOpPermission(ctx context.Context, req *dmsCommonV1.GetUserOpPermissionReq) (reply *dmsCommonV1.GetUserOpPermissionReply, err error) {
isAdmin, err := d.OpPermissionVerifyUsecase.IsUserProjectAdmin(ctx, req.UserUid, req.UserOpPermission.ProjectUid)
// 兼容新旧版本获取项目ID方式
projectUid := req.ProjectUid
if projectUid == "" && req.UserOpPermission != nil {
projectUid = req.UserOpPermission.ProjectUid
}

isAdmin, err := d.OpPermissionVerifyUsecase.IsUserProjectAdmin(ctx, req.UserUid, projectUid)
if err != nil {
return nil, fmt.Errorf("check user admin error: %v", err)
}

permissions, err := d.OpPermissionVerifyUsecase.GetUserOpPermissionInProject(ctx, req.UserUid, req.UserOpPermission.ProjectUid)
permissions, err := d.OpPermissionVerifyUsecase.GetUserOpPermissionInProject(ctx, req.UserUid, projectUid)
if err != nil {
return nil, fmt.Errorf("get user op permission error: %v", err)
}
Expand Down
6 changes: 5 additions & 1 deletion pkg/dms-common/api/dms/v1/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ type GetUserOpPermissionReq struct {
// user uid
// in:path
UserUid string `param:"user_uid" json:"user_uid" validate:"required"`

// in:query
// uesr project uid
ProjectUid string `json:"project_uid" query:"project_uid"`
// user op permission info
// in:body
UserOpPermission *UserOpPermission `json:"user_op_permission" validate:"required"`
UserOpPermission *UserOpPermission `json:"user_op_permission" `
}

type UserOpPermission struct {
Expand Down

0 comments on commit 4982d48

Please sign in to comment.