|
15 | 15 | from common.auth.authentication import has_permissions |
16 | 16 | from common.constants.permission_constants import PermissionConstants, Permission, Group, Operate |
17 | 17 | from common.result import result |
| 18 | +from maxkb.const import CONFIG |
18 | 19 | from models_provider.api.model import DefaultModelResponse |
19 | 20 | from users.api.user import UserProfileAPI, TestWorkspacePermissionUserApi, DeleteUserApi, EditUserApi, \ |
20 | | - ChangeUserPasswordApi, UserPageApi, UserListApi |
| 21 | + ChangeUserPasswordApi, UserPageApi, UserListApi, UserPasswordResponse |
21 | 22 | from users.serializers.user import UserProfileSerializer, UserManageSerializer |
22 | 23 |
|
| 24 | +default_password = CONFIG.get('default_password', 'MaxKB@123..') |
| 25 | + |
23 | 26 |
|
24 | 27 | class UserProfileView(APIView): |
25 | 28 | authentication_classes = [TokenAuth] |
@@ -77,6 +80,19 @@ class UserManage(APIView): |
77 | 80 | def post(self, request: Request): |
78 | 81 | return result.success(UserManageSerializer().save(request.data)) |
79 | 82 |
|
| 83 | + class Password(APIView): |
| 84 | + authentication_classes = [TokenAuth] |
| 85 | + |
| 86 | + @extend_schema(methods=['Get'], |
| 87 | + summary=_("Get default password"), |
| 88 | + description=_("Get default password"), |
| 89 | + operation_id=_("Get default password"), # type: ignore |
| 90 | + tags=[_("User management")], # type: ignore |
| 91 | + responses=UserPasswordResponse.get_response()) |
| 92 | + @has_permissions(PermissionConstants.USER_CREATE) |
| 93 | + def get(self, request: Request): |
| 94 | + return result.success(data={'password': default_password}) |
| 95 | + |
80 | 96 | class Operate(APIView): |
81 | 97 | authentication_classes = [TokenAuth] |
82 | 98 |
|
|
0 commit comments