优化初次登录改密码
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package io.v.nutz.zhgh.mobile;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.wizzer.framework.base.Result;
|
||||
import io.v.nutz.base.utils.LoginUtil;
|
||||
import io.v.nutz.base.utils.PwdUtil;
|
||||
@@ -21,8 +22,6 @@ import org.apache.shiro.subject.Subject;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
@@ -127,18 +126,16 @@ public class mobileLoginController {
|
||||
@Param("isFirstLogin") boolean isFirstLogin, @Param("newPwd") String newPwd) {
|
||||
Sys_user user = dao.fetch(Sys_user.class, Cnd.where("id", "=", ShiroUtil.getUserId()));
|
||||
|
||||
if (isFirstLogin) {
|
||||
sourcePwd = user.getLoginname();
|
||||
}
|
||||
if (!isFirstLogin) {
|
||||
String userSourcePwd = PwdUtil.doSm4CbcDecrypt(user.getPassword());
|
||||
|
||||
String userSourcePwd = PwdUtil.doSm4CbcDecrypt(user.getPassword());
|
||||
if (!userSourcePwd.equals(sourcePwd)) {
|
||||
return Result.error("原密码错误");
|
||||
}
|
||||
|
||||
if (!userSourcePwd.equals(sourcePwd)) {
|
||||
return Result.error("原密码错误");
|
||||
}
|
||||
|
||||
if (userSourcePwd.equals(newPwd)) {
|
||||
return Result.error("新密码不能与原密码相同");
|
||||
if (userSourcePwd.equals(newPwd)) {
|
||||
return Result.error("新密码不能与原密码相同");
|
||||
}
|
||||
}
|
||||
|
||||
String pwd = PwdUtil.doSm4CbcEncrypt(newPwd);
|
||||
@@ -156,10 +153,11 @@ public class mobileLoginController {
|
||||
@At
|
||||
@RequiresAuthentication
|
||||
public Object checkIsFirstLogin(){
|
||||
Sql sql = Sqls.create("select weAppLoginCount from sys_user where id = @userId").setParam("userId", ShiroUtil.getUserId());
|
||||
sql.setCallback(Sqls.callback.integer());
|
||||
dao.execute(sql);
|
||||
int count = sql.getInt();
|
||||
return count == 1 ? Result.error() : Result.success();
|
||||
Sys_user user = dao.fetch(Sys_user.class, Cnd.where("id", "=", ShiroUtil.getUserId()));
|
||||
if (user.getWeAppLoginCount() == 1 && StrUtil.isNotBlank(user.getOpenId())) {
|
||||
return Result.error();
|
||||
} else {
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ layout("/mobile/platform.html"){
|
||||
<mobile-sign-points></mobile-sign-points>
|
||||
</van-popup>
|
||||
|
||||
<van-popup v-model="updatePwdShow" class="pwd_popup">
|
||||
<van-popup v-model="updatePwdShow" class="pwd_popup" :close-on-click-overlay="false" :closeable="!formData.isFirstLogin">
|
||||
<div class="card modify-password">
|
||||
<div class="card-content">
|
||||
<h2>{{ formData.isFirstLogin ? '首次登录,请修改密码' : '修改密码' }}</h2>
|
||||
@@ -452,12 +452,12 @@ layout("/mobile/platform.html"){
|
||||
<span class="toggle-password" data-target="current-password">🔒</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="new-password">新密码</label>
|
||||
<label for="new-password">请输入新密码</label>
|
||||
<input type="password" id="new-password" name="new-password" maxlength="20" v-model="formData.newPwd" @blur="checkPwd" />
|
||||
<span class="toggle-password" data-target="new-password">🔒</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="confirm-password">确认新密码</label>
|
||||
<label for="confirm-password">请再次输入新密码</label>
|
||||
<input
|
||||
type="password"
|
||||
id="confirm-password"
|
||||
@@ -531,6 +531,14 @@ layout("/mobile/platform.html"){
|
||||
if (!this.formData.isFirstLogin && !this.formData.sourcePwd) {
|
||||
this.$toast("请输入原密码")
|
||||
}
|
||||
if (!this.formData.newPwd) {
|
||||
this.$toast("请输入新密码")
|
||||
return
|
||||
}
|
||||
if (!this.formData.confirmPwd) {
|
||||
this.$toast("请再次输入新密码")
|
||||
return
|
||||
}
|
||||
const resp = await $.post("/mobile/login/updatePwd", this.formData)
|
||||
if (resp.code === 0) {
|
||||
this.$toast("修改成功")
|
||||
@@ -555,8 +563,8 @@ layout("/mobile/platform.html"){
|
||||
checkConfirmPwd() {
|
||||
// 检验输入是否大于6位数
|
||||
if (!this.formData.confirmPwd) {
|
||||
this.errorInfo = "请输入确认新密码"
|
||||
this.$toast("请输入确认新密码")
|
||||
this.errorInfo = "请再次输入新密码"
|
||||
this.$toast("请再次输入新密码")
|
||||
return
|
||||
}
|
||||
if (this.formData.confirmPwd.length < 6) {
|
||||
@@ -565,8 +573,8 @@ layout("/mobile/platform.html"){
|
||||
return
|
||||
}
|
||||
if (this.formData.newPwd !== this.formData.confirmPwd) {
|
||||
this.errorInfo = "新密码与确认新密码不一致"
|
||||
this.$toast("新密码与确认新密码不一致")
|
||||
this.errorInfo = "新密码与再次输入新密码不一致"
|
||||
this.$toast("新密码与再次输入新密码不一致")
|
||||
return
|
||||
}
|
||||
this.errorInfo = ""
|
||||
|
||||
@@ -2497,6 +2497,9 @@ layout("/layouts/platform.html"){
|
||||
const resp = await $.post(loc() + "/activityData", this.pageForm)
|
||||
if (resp.code === 0) {
|
||||
this.activityList = resp.data
|
||||
if (this.activityList) {
|
||||
await this.openApply(this.activityList[0])
|
||||
}
|
||||
} else {
|
||||
this.notifyWarning(resp.msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user