用户初次登录修改密码优化
This commit is contained in:
@@ -335,7 +335,8 @@ class UserViewSet(CustomModelViewSet):
|
|||||||
old_pwd_md5 = hashlib.md5(old_pwd_md5.encode(encoding='UTF-8')).hexdigest()
|
old_pwd_md5 = hashlib.md5(old_pwd_md5.encode(encoding='UTF-8')).hexdigest()
|
||||||
verify_password = check_password(str(old_pwd_md5), request.user.password)
|
verify_password = check_password(str(old_pwd_md5), request.user.password)
|
||||||
if verify_password:
|
if verify_password:
|
||||||
request.user.password = make_password(hashlib.md5(new_pwd.encode(encoding='UTF-8')).hexdigest())
|
# request.user.password = make_password(hashlib.md5(new_pwd.encode(encoding='UTF-8')).hexdigest())
|
||||||
|
request.user.password = make_password(new_pwd)
|
||||||
request.user.pwd_change_count += 1
|
request.user.pwd_change_count += 1
|
||||||
request.user.save()
|
request.user.save()
|
||||||
return DetailResponse(data=None, msg="修改成功")
|
return DetailResponse(data=None, msg="修改成功")
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-form ref="formRef" size="large" class="login-content-form" :model="state.ruleForm" :rules="rules" @keyup.enter="loginClick">
|
<el-form ref="formRef" size="large" class="login-content-form" :model="state.ruleForm" :rules="rules"
|
||||||
|
@keyup.enter="loginClick">
|
||||||
<el-form-item class="login-animation1" prop="username">
|
<el-form-item class="login-animation1" prop="username">
|
||||||
<el-input type="text" :placeholder="$t('message.account.accountPlaceholder1')" readonly v-model="ruleForm.username"
|
<el-input type="text" :placeholder="$t('message.account.accountPlaceholder1')" readonly
|
||||||
clearable autocomplete="off">
|
v-model="ruleForm.username" clearable autocomplete="off">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon"><ele-User /></el-icon>
|
<el-icon class="el-input__icon"><ele-User /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="login-animation2" prop="password">
|
<el-form-item class="login-animation2" prop="password">
|
||||||
<el-input :type="isShowPassword ? 'text' : 'password'" :placeholder="$t('message.account.accountPlaceholder4')"
|
<el-input :type="isShowPassword ? 'text' : 'password'"
|
||||||
v-model="ruleForm.password">
|
:placeholder="$t('message.account.accountPlaceholder4')" v-model="ruleForm.password">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon"><ele-Unlock /></el-icon>
|
<el-icon class="el-input__icon"><ele-Unlock /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
@@ -23,8 +24,8 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="login-animation3" prop="password_regain">
|
<el-form-item class="login-animation3" prop="password_regain">
|
||||||
<el-input :type="isShowPassword ? 'text' : 'password'" :placeholder="$t('message.account.accountPlaceholder5')"
|
<el-input :type="isShowPassword ? 'text' : 'password'"
|
||||||
v-model="ruleForm.password_regain">
|
:placeholder="$t('message.account.accountPlaceholder5')" v-model="ruleForm.password_regain">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<el-icon class="el-input__icon"><ele-Unlock /></el-icon>
|
<el-icon class="el-input__icon"><ele-Unlock /></el-icon>
|
||||||
</template>
|
</template>
|
||||||
@@ -37,8 +38,7 @@
|
|||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="login-animation4">
|
<el-form-item class="login-animation4">
|
||||||
<el-button type="primary" class="login-content-submit" round @click="loginClick"
|
<el-button type="primary" class="login-content-submit" round @click="loginClick" :loading="loading.signIn">
|
||||||
:loading="loading.signIn">
|
|
||||||
<span>{{ $t('message.account.accountBtnText') }}</span>
|
<span>{{ $t('message.account.accountBtnText') }}</span>
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -159,7 +159,7 @@ export default defineComponent({
|
|||||||
if (!formRef.value) return
|
if (!formRef.value) return
|
||||||
await formRef.value.validate((valid: any) => {
|
await formRef.value.validate((valid: any) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
loginApi.loginChangePwd({ ...state.ruleForm, password: state.ruleForm.password,password_regain: state.ruleForm.password_regain }).then((res: any) => {
|
loginApi.loginChangePwd({ ...state.ruleForm, password: Md5.hashStr(state.ruleForm.password), password_regain: Md5.hashStr(state.ruleForm.password_regain) }).then((res: any) => {
|
||||||
if (res.code === 2000) {
|
if (res.code === 2000) {
|
||||||
if (!themeConfig.value.isRequestRoutes) {
|
if (!themeConfig.value.isRequestRoutes) {
|
||||||
// 前端控制路由,2、请注意执行顺序
|
// 前端控制路由,2、请注意执行顺序
|
||||||
|
|||||||
Reference in New Issue
Block a user