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