Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/dms/biz/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type User struct {
LastLoginAt time.Time
// 用户是否被删除
Deleted bool
// 业务写权开关,默认 true;为 false 时系统管理员/admin 不通过全局身份放行业务写操作
// 业务写权开关,为 false 时系统管理员/admin 不通过全局身份放行业务写操作
BusinessWritePermission bool
}

Expand Down Expand Up @@ -506,7 +506,7 @@ type CreateUserArgs struct {
OpPermissionUIDs []string
UserAuthenticationType UserAuthenticationType
System UserSystem
BusinessWritePermission *bool // nil means use default (true)
BusinessWritePermission *bool
}

func (d *UserUsecase) AddUser(ctx context.Context, currentUserUid string, args *CreateUserArgs) (uid string, err error) {
Expand Down Expand Up @@ -885,8 +885,8 @@ func (d *UserUsecase) UpdateUser(ctx context.Context, currentUserUid string, arg
user.BusinessWritePermission = *args.BusinessWritePermission
}
} else {
// User is not system administrator: always reset BWP to true
user.BusinessWritePermission = true
// User is not system administrator: always reset BWP to flase
user.BusinessWritePermission = false
}
}

Expand Down
13 changes: 12 additions & 1 deletion internal/dms/service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ func (d *DMSService) AddUser(ctx context.Context, currentUserUid string, req *dm
defer func() {
d.log.Infof("AddUsers.req=%v;reply=%v;error=%v", req, reply, err)
}()
// 如果 BusinessWritePermission 为 nil,如果为系统管理员权限,默认有业务写权限
businessWritePermission := req.User.BusinessWritePermission
if businessWritePermission == nil {
for _, uid := range req.User.OpPermissionUids {
if uid == pkgConst.UIDOfOpPermissionGlobalManagement {
t := true
businessWritePermission = &t
break
}
}
}

args := &biz.CreateUserArgs{
UID: req.User.UID,
Expand All @@ -111,7 +122,7 @@ func (d *DMSService) AddUser(ctx context.Context, currentUserUid string, req *dm
ThirdPartyUserID: req.User.ThirdPartyUserID,
ThirdPartyUserInfo: req.User.ThirdPartyUserInfo,
UserAuthenticationType: biz.UserAuthenticationType(req.User.UserAuthenticationType),
BusinessWritePermission: req.User.BusinessWritePermission,
BusinessWritePermission: businessWritePermission,
}

uid, err := d.UserUsecase.AddUser(ctx, currentUserUid, args)
Expand Down