优化初次登录改密码
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user