refactor: user add default password
This commit is contained in:
parent
c3581be9bd
commit
4eed42b6a0
@ -3311,3 +3311,6 @@ msgstr ""
|
|||||||
#: apps/users/views/user.py:139
|
#: apps/users/views/user.py:139
|
||||||
msgid "Get user paginated list"
|
msgid "Get user paginated list"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Get default password"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@ -3489,3 +3489,5 @@ msgstr "修改密码"
|
|||||||
msgid "Get user paginated list"
|
msgid "Get user paginated list"
|
||||||
msgstr "获取用户分页列表"
|
msgstr "获取用户分页列表"
|
||||||
|
|
||||||
|
msgid "Get default password"
|
||||||
|
msgstr "获取默认密码"
|
||||||
@ -3489,3 +3489,6 @@ msgstr "修改密碼"
|
|||||||
msgid "Get user paginated list"
|
msgid "Get user paginated list"
|
||||||
msgstr "獲取用戶分頁列表"
|
msgstr "獲取用戶分頁列表"
|
||||||
|
|
||||||
|
msgid "Get default password"
|
||||||
|
msgstr "獲取默認密碼"
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,22 @@ class UserProfileAPI(APIMixin):
|
|||||||
)]
|
)]
|
||||||
|
|
||||||
|
|
||||||
|
class UserPasswordResponse(APIMixin):
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get_response():
|
||||||
|
return PasswordResponse
|
||||||
|
|
||||||
|
|
||||||
|
class Password(serializers.Serializer):
|
||||||
|
password = serializers.CharField(required=True, label=_('Password'))
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordResponse(ResultSerializer):
|
||||||
|
def get_data(self):
|
||||||
|
return Password()
|
||||||
|
|
||||||
|
|
||||||
class EditUserApi(APIMixin):
|
class EditUserApi(APIMixin):
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_parameters():
|
def get_parameters():
|
||||||
|
|||||||
@ -11,6 +11,7 @@ urlpatterns = [
|
|||||||
path('workspace/<str:workspace_id>/user/profile', views.TestWorkspacePermissionUserView.as_view(),
|
path('workspace/<str:workspace_id>/user/profile', views.TestWorkspacePermissionUserView.as_view(),
|
||||||
name="test_workspace_id_permission"),
|
name="test_workspace_id_permission"),
|
||||||
path("user_manage", views.UserManage.as_view(), name="user_manage"),
|
path("user_manage", views.UserManage.as_view(), name="user_manage"),
|
||||||
|
path("user_manage/password", views.UserManage.Password.as_view()),
|
||||||
path("user_manage/<str:user_id>", views.UserManage.Operate.as_view(), name="user_manage_operate"),
|
path("user_manage/<str:user_id>", views.UserManage.Operate.as_view(), name="user_manage_operate"),
|
||||||
path("user_manage/<str:user_id>/re_password", views.UserManage.RePassword.as_view(),
|
path("user_manage/<str:user_id>/re_password", views.UserManage.RePassword.as_view(),
|
||||||
name="user_manage_re_password"),
|
name="user_manage_re_password"),
|
||||||
|
|||||||
@ -15,11 +15,14 @@ from common.auth.authenticate import TokenAuth
|
|||||||
from common.auth.authentication import has_permissions
|
from common.auth.authentication import has_permissions
|
||||||
from common.constants.permission_constants import PermissionConstants, Permission, Group, Operate
|
from common.constants.permission_constants import PermissionConstants, Permission, Group, Operate
|
||||||
from common.result import result
|
from common.result import result
|
||||||
|
from maxkb.const import CONFIG
|
||||||
from models_provider.api.model import DefaultModelResponse
|
from models_provider.api.model import DefaultModelResponse
|
||||||
from users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi, DeleteUserApi, EditUserApi, \
|
from users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi, DeleteUserApi, EditUserApi, \
|
||||||
ChangeUserPasswordApi, UserPageApi, UserListApi
|
ChangeUserPasswordApi, UserPageApi, UserListApi, UserPasswordResponse
|
||||||
from users.serializers.user import UserProfileSerializer, UserManageSerializer
|
from users.serializers.user import UserProfileSerializer, UserManageSerializer
|
||||||
|
|
||||||
|
default_password = CONFIG.get('default_password', 'MaxKB@123..')
|
||||||
|
|
||||||
|
|
||||||
class UserProfileView(APIView):
|
class UserProfileView(APIView):
|
||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
@ -77,6 +80,19 @@ class UserManage(APIView):
|
|||||||
def post(self, request: Request):
|
def post(self, request: Request):
|
||||||
return result.success(UserManageSerializer().save(request.data))
|
return result.success(UserManageSerializer().save(request.data))
|
||||||
|
|
||||||
|
class Password(APIView):
|
||||||
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
@extend_schema(methods=['Get'],
|
||||||
|
summary=_("Get default password"),
|
||||||
|
description=_("Get default password"),
|
||||||
|
operation_id=_("Get default password"), # type: ignore
|
||||||
|
tags=[_("User management")], # type: ignore
|
||||||
|
responses=UserPasswordResponse.get_response())
|
||||||
|
@has_permissions(PermissionConstants.USER_CREATE)
|
||||||
|
def get(self, request: Request):
|
||||||
|
return result.success(data={'password': default_password})
|
||||||
|
|
||||||
class Operate(APIView):
|
class Operate(APIView):
|
||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user