feat: user admin reset password

This commit is contained in:
xtaodada 2024-11-16 15:15:53 +08:00
parent 05021865c7
commit 06fb366b5a
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
28 changed files with 56 additions and 26 deletions

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="https://unpkg.com/wangeditor@4.7.8/dist/wangEditor.min.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
/* .data-table .el-table__body-wrapper{min-height: 0px; max-height: 0px;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
/* 流体input */

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.c-panel .el-form .el-input,

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.c-panel .c-label{width: 10em;}

View File

@ -77,7 +77,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="https://unpkg.com/echarts@4.6.0/dist/echarts-en.min.js"></script>
<script src="../../static/sa.js"></script>
<script type="text/javascript">

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<script src="../../static/kj/upload-util.js"></script>
<style type="text/css">

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style>
.td-img{width: 90px; height: 90px; cursor: pointer; vertical-align: middle;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<script src="../../static/kj/upload-util.js"></script>
<style type="text/css">

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style>
.td-img{width: 180px; height: 90px; cursor: pointer; vertical-align: middle;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style>
body,.el-tree{background-color: #eee;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style>
body,.el-tree{background-color: #eee;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.c-panel .el-form .c-label{width: 6em !important;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -30,7 +30,7 @@
</div>
<script src="https://unpkg.com/marked@0.8.0/marked.min.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<script type="text/javascript">

View File

@ -12,7 +12,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="https://unpkg.com/wangeditor@4.7.8/dist/wangEditor.min.js"></script>
<script src="../../static/sa.js"></script>
<script src="../../static/kj/upload-util.js"></script>

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.c-panel .el-form .c-label{width: 6em !important;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.c-panel .c-label{width: 8em;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style>
.avatar-uploader .el-upload {

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
<style type="text/css">
.echarts-div {height:70vh;}

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>
@ -113,6 +113,7 @@
<el-table-column prop="address" label="操作">
<template slot-scope="s">
<el-button class="c-btn" type="success" icon="el-icon-view" @click="get(s.row)">详情</el-button>
<el-button class="c-btn" type="danger" icon="el-icon-delete" @click="reset_pwd(s.row)">重置密码</el-button>
<el-button class="c-btn" type="danger" icon="el-icon-delete" @click="del(s.row)">禁/启用</el-button>
</template>
</el-table-column>
@ -215,6 +216,14 @@
}.bind(this), {})
}.bind(this));
},
// 重置密码
reset_pwd: function (data) {
sa.confirm('是否重置密码,此操作不可撤销', function() {
sa.ajax('/user/admin/reset_password', {user_id: data.id}, function(res) {
sa.ok('重置密码成功');
}.bind(this), {})
}.bind(this));
},
// 批量删除
deleteByIds: function() {
// 获取选中元素的id列表

View File

@ -11,7 +11,7 @@
<script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
<script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
<script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
<script src="https://www.layuicdn.com/layer-v3.1.1/layer.js"></script>
<script src="../../static/kj/layer/layer.js"></script>
<script src="../../static/sa.js"></script>
</head>
<body>

View File

@ -87,3 +87,16 @@ class UserAdminRoutes(Plugin):
create_type = CreateTypeEnum.ADMIN
user = await self.user_routes.create_user(data, create_type, role)
return BaseApiOut(code=0, msg="注册成功", data=user)
@handler.post("/reset_password", student=True)
async def reset_password(self, data: DisableOrEnableUser):
try:
result = await self.user_services.reset_password(data.user_id)
if not result:
return BaseApiOut(code=500, msg="操作失败")
return BaseApiOut(code=0, msg="重置成功", data={})
except Exception as e:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=f"Error Execute SQL{e}",
) from e

View File

@ -146,6 +146,14 @@ class UserServices(AsyncInitializingComponent):
await self.repo.update_user(user)
return True
async def reset_password(self, user_id: int) -> bool:
user = await self.get_user(user_id)
if not user:
return False
user.password = self.repo.AUTH.pwd_context.hash("123456")
await self.repo.update_user(user)
return True
class UserRoleServices(AsyncInitializingComponent):
__order__ = 1