Skip to content

Commit 4e5285c

Browse files
committed
refactor: permission
1 parent 395f3f9 commit 4e5285c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

apps/users/views/user.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ class SwitchUserLanguageView(APIView):
9393
)
9494
@log(menu='User management', operate='Switch Language',
9595
get_operation_object=lambda r, k: {'name': r.user.username})
96+
@has_permissions(PermissionConstants.SWITCH_LANGUAGE, RoleConstants.ADMIN, RoleConstants.USER,
97+
RoleConstants.WORKSPACE_MANAGE)
9698
def post(self, request: Request):
9799
data = {**request.data, 'user_id': request.user.id}
98100
return result.success(SwitchLanguageSerializer(data=data).switch())
@@ -206,7 +208,7 @@ def delete(self, request: Request, user_id):
206208
tags=[_("User Management")], # type: ignore
207209
request=DeleteUserApi.get_parameters(),
208210
responses=UserProfileAPI.get_response())
209-
@has_permissions(PermissionConstants.USER_READ,RoleConstants.ADMIN)
211+
@has_permissions(PermissionConstants.USER_READ, RoleConstants.ADMIN)
210212
def get(self, request: Request, user_id):
211213
return result.success(UserManageSerializer.Operate(data={'id': user_id}).one(with_valid=True))
212214

@@ -269,7 +271,7 @@ class Page(APIView):
269271
tags=[_("User Management")], # type: ignore
270272
parameters=UserPageApi.get_parameters(),
271273
responses=UserPageApi.get_response())
272-
@has_permissions(PermissionConstants.USER_READ,RoleConstants.ADMIN)
274+
@has_permissions(PermissionConstants.USER_READ, RoleConstants.ADMIN)
273275
def get(self, request: Request, current_page, page_size):
274276
d = UserManageSerializer.Query(
275277
data={'email_or_username': request.query_params.get('email_or_username', None),
@@ -359,6 +361,8 @@ class ResetCurrentUserPasswordView(APIView):
359361
@log(menu='User management', operate='Modify current user password',
360362
get_operation_object=lambda r, k: {'name': r.user.username},
361363
get_details=get_re_password_details)
364+
@has_permissions(PermissionConstants.CHANGE_PASSWORD, RoleConstants.ADMIN, RoleConstants.USER,
365+
RoleConstants.WORKSPACE_MANAGE)
362366
def post(self, request: Request):
363367
serializer_obj = RePasswordSerializer(data=request.data)
364368
if serializer_obj.reset_password(request.user.id):

0 commit comments

Comments
 (0)