feat: user admin reset password
This commit is contained in:
parent
05021865c7
commit
06fb366b5a
@ -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">
|
||||
|
@ -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;}
|
||||
|
@ -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>
|
||||
|
@ -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 */
|
||||
|
@ -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>
|
||||
|
@ -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,
|
||||
|
@ -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;}
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
@ -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;}
|
||||
|
@ -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">
|
||||
|
@ -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;}
|
||||
|
@ -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;}
|
||||
|
@ -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;}
|
||||
|
@ -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;}
|
||||
|
@ -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>
|
||||
|
@ -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">
|
||||
|
||||
|
@ -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>
|
||||
|
@ -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;}
|
||||
|
@ -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;}
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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 {
|
||||
|
@ -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;}
|
||||
|
@ -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列表
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user