fix:修改密码相关功能
parent
2aaccc1193
commit
1545771196
|
|
@ -29,7 +29,6 @@ export function login(username, password, code, rememberMe) {
|
||||||
export function resetLoginPwd(data) {
|
export function resetLoginPwd(data) {
|
||||||
const formData = createLoginFormData({
|
const formData = createLoginFormData({
|
||||||
username: data.username,
|
username: data.username,
|
||||||
oldPassword: data.oldPassword,
|
|
||||||
newPassword: data.newPassword,
|
newPassword: data.newPassword,
|
||||||
confirmPassword: data.confirmPassword,
|
confirmPassword: data.confirmPassword,
|
||||||
emailCode: data.emailCode
|
emailCode: data.emailCode
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,10 @@
|
||||||
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
<img :src="codeUrl" @click="getCode" class="login-code-img"/>
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-checkbox v-model="loginForm.rememberMe" style="margin:0px 0px 25px 0px;">记住密码</el-checkbox>
|
<div class="login-options">
|
||||||
|
<el-checkbox v-model="loginForm.rememberMe">记住密码</el-checkbox>
|
||||||
|
<span class="link-type forgot-password" @click="openResetPwdDialog">忘记密码?</span>
|
||||||
|
</div>
|
||||||
<el-form-item style="width:100%;">
|
<el-form-item style="width:100%;">
|
||||||
<el-button
|
<el-button
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
|
|
@ -64,8 +67,8 @@
|
||||||
append-to-body
|
append-to-body
|
||||||
>
|
>
|
||||||
<el-form ref="resetPwdForm" :model="resetPwdForm" :rules="resetPwdRules" label-width="100px">
|
<el-form ref="resetPwdForm" :model="resetPwdForm" :rules="resetPwdRules" label-width="100px">
|
||||||
<el-form-item label="旧密码" prop="oldPassword">
|
<el-form-item label="用户名" prop="username">
|
||||||
<el-input v-model="resetPwdForm.oldPassword" type="password" placeholder="请输入旧密码" show-password />
|
<el-input v-model="resetPwdForm.username" placeholder="请输入用户名" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="新密码" prop="newPassword">
|
<el-form-item label="新密码" prop="newPassword">
|
||||||
<el-input v-model="resetPwdForm.newPassword" type="password" placeholder="请输入新密码" show-password />
|
<el-input v-model="resetPwdForm.newPassword" type="password" placeholder="请输入新密码" show-password />
|
||||||
|
|
@ -111,7 +114,6 @@ export default {
|
||||||
},
|
},
|
||||||
resetPwdForm: {
|
resetPwdForm: {
|
||||||
username: "",
|
username: "",
|
||||||
oldPassword: "",
|
|
||||||
newPassword: "",
|
newPassword: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
emailCode: ""
|
emailCode: ""
|
||||||
|
|
@ -122,8 +124,8 @@ export default {
|
||||||
emailCodeCountdown: 0,
|
emailCodeCountdown: 0,
|
||||||
emailCodeTimer: null,
|
emailCodeTimer: null,
|
||||||
resetPwdRules: {
|
resetPwdRules: {
|
||||||
oldPassword: [
|
username: [
|
||||||
{ required: true, trigger: "blur", message: "请输入旧密码" }
|
{ required: true, trigger: "blur", message: "请输入用户名" }
|
||||||
],
|
],
|
||||||
newPassword: [
|
newPassword: [
|
||||||
{ required: true, trigger: "blur", message: "请输入新密码" },
|
{ required: true, trigger: "blur", message: "请输入新密码" },
|
||||||
|
|
@ -201,7 +203,6 @@ export default {
|
||||||
this.clearEmailCodeTimer()
|
this.clearEmailCodeTimer()
|
||||||
this.resetPwdForm = {
|
this.resetPwdForm = {
|
||||||
username: this.loginForm.username,
|
username: this.loginForm.username,
|
||||||
oldPassword: "",
|
|
||||||
newPassword: "",
|
newPassword: "",
|
||||||
confirmPassword: "",
|
confirmPassword: "",
|
||||||
emailCode: ""
|
emailCode: ""
|
||||||
|
|
@ -213,16 +214,17 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
sendEmailCode() {
|
sendEmailCode() {
|
||||||
if (!this.resetPwdForm.username) {
|
this.$refs.resetPwdForm.validateField('username', (errorMessage) => {
|
||||||
this.$modal.msgError("请输入用户名")
|
if (errorMessage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.emailCodeLoading = true
|
this.emailCodeLoading = true
|
||||||
sendResetPwdEmailCode(this.resetPwdForm.username).then(() => {
|
sendResetPwdEmailCode(this.resetPwdForm.username).then(() => {
|
||||||
this.$modal.msgSuccess("验证码已发送")
|
this.$modal.msgSuccess("验证码已发送")
|
||||||
this.startEmailCodeCountdown()
|
this.startEmailCodeCountdown()
|
||||||
}).finally(() => {
|
}).finally(() => {
|
||||||
this.emailCodeLoading = false
|
this.emailCodeLoading = false
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
startEmailCodeCountdown() {
|
startEmailCodeCountdown() {
|
||||||
|
|
@ -279,7 +281,6 @@ export default {
|
||||||
this.$store.dispatch("Login", this.loginForm).then((res) => {
|
this.$store.dispatch("Login", this.loginForm).then((res) => {
|
||||||
if (res && res.code === 301) {
|
if (res && res.code === 301) {
|
||||||
this.resetPwdForm.username = this.loginForm.username
|
this.resetPwdForm.username = this.loginForm.username
|
||||||
this.resetPwdForm.oldPassword = this.loginForm.password
|
|
||||||
this.resetPwdForm.newPassword = ""
|
this.resetPwdForm.newPassword = ""
|
||||||
this.resetPwdForm.confirmPassword = ""
|
this.resetPwdForm.confirmPassword = ""
|
||||||
this.resetPwdForm.emailCode = ""
|
this.resetPwdForm.emailCode = ""
|
||||||
|
|
@ -325,50 +326,63 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
width: 400px;
|
width: 400px;
|
||||||
padding: 25px 25px 5px 25px;
|
padding: 25px 25px 5px 25px;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
.el-input {
|
.el-input {
|
||||||
height: 38px;
|
|
||||||
input {
|
|
||||||
height: 38px;
|
height: 38px;
|
||||||
|
input {
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.input-icon {
|
||||||
|
height: 39px;
|
||||||
|
width: 14px;
|
||||||
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.input-icon {
|
.login-options {
|
||||||
height: 39px;
|
display: flex;
|
||||||
width: 14px;
|
align-items: center;
|
||||||
margin-left: 2px;
|
justify-content: space-between;
|
||||||
|
margin: 0px 0px 25px 0px;
|
||||||
}
|
}
|
||||||
|
.forgot-password {
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
.login-tip {
|
.forgot-password:hover {
|
||||||
font-size: 13px;
|
text-decoration: underline;
|
||||||
text-align: center;
|
}
|
||||||
color: #bfbfbf;
|
.login-tip {
|
||||||
}
|
font-size: 13px;
|
||||||
.login-code {
|
text-align: center;
|
||||||
width: 33%;
|
color: #bfbfbf;
|
||||||
height: 38px;
|
}
|
||||||
float: right;
|
.login-code {
|
||||||
img {
|
width: 33%;
|
||||||
cursor: pointer;
|
height: 38px;
|
||||||
vertical-align: middle;
|
float: right;
|
||||||
|
img {
|
||||||
|
cursor: pointer;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.el-login-footer {
|
||||||
|
height: 40px;
|
||||||
|
line-height: 40px;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
color: #fff;
|
||||||
|
font-family: Arial;
|
||||||
|
font-size: 12px;
|
||||||
|
letter-spacing: 1px;
|
||||||
|
}
|
||||||
|
.login-code-img {
|
||||||
|
height: 38px;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.el-login-footer {
|
|
||||||
height: 40px;
|
|
||||||
line-height: 40px;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
text-align: center;
|
|
||||||
color: #fff;
|
|
||||||
font-family: Arial;
|
|
||||||
font-size: 12px;
|
|
||||||
letter-spacing: 1px;
|
|
||||||
}
|
|
||||||
.login-code-img {
|
|
||||||
height: 38px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -92,11 +92,11 @@ public class SysLoginController extends BaseController
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
subject.login(token);
|
subject.login(token);
|
||||||
// if (!passwordService.isStrongPassword(password))
|
if (!passwordService.isStrongPassword(password))
|
||||||
// {
|
{
|
||||||
// subject.logout();
|
subject.logout();
|
||||||
// return AjaxResult.warn("当前密码不符合安全规则,请修改密码后重新登录");
|
return AjaxResult.warn("当前密码不符合安全规则,请修改密码后重新登录");
|
||||||
// }
|
}
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
catch (AuthenticationException e)
|
catch (AuthenticationException e)
|
||||||
|
|
@ -153,7 +153,7 @@ public class SysLoginController extends BaseController
|
||||||
|
|
||||||
@PostMapping("/login/resetPwd")
|
@PostMapping("/login/resetPwd")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public AjaxResult resetPwd(String username, String oldPassword, String newPassword, String confirmPassword, String emailCode)
|
public AjaxResult resetPwd(String username, String newPassword, String confirmPassword, String emailCode)
|
||||||
{
|
{
|
||||||
if (StringUtils.isEmpty(username))
|
if (StringUtils.isEmpty(username))
|
||||||
{
|
{
|
||||||
|
|
@ -185,10 +185,6 @@ public class SysLoginController extends BaseController
|
||||||
{
|
{
|
||||||
return emailCodeValidateResult;
|
return emailCodeValidateResult;
|
||||||
}
|
}
|
||||||
if (!passwordService.matches(user, oldPassword))
|
|
||||||
{
|
|
||||||
return error("修改密码失败,旧密码错误");
|
|
||||||
}
|
|
||||||
if (passwordService.matches(user, newPassword))
|
if (passwordService.matches(user, newPassword))
|
||||||
{
|
{
|
||||||
return error("新密码不能与旧密码相同");
|
return error("新密码不能与旧密码相同");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue