Commit 2bfe1e9d authored by 李德才's avatar 李德才

更换登录方法获取用户和系统的方式

parent 7ef9bc89
package com.archser.aserver.controller;
import com.archser.aserver.util.redis.InfoSystem;
import com.archser.aserver.util.redis.InfoUser;
import com.archser.aserver.util.redis.RedisConvert;
import com.jfinal.kit.JsonKit;
import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
......@@ -118,7 +122,7 @@ public class IndexController extends Controller {
//校验密码是否符合强度设置
String verify = password;
password = HashKit.sha256(password);
User user = User.dao.template("getUser", username).findFirst();
User user = InfoUser.getUser(username);
if (user == null) {
this.renderJson(Ret.fail("msg", "用户名或密码不存在: " + username));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "该用户非本系统用户正在非法登录", app);
......@@ -148,14 +152,14 @@ public class IndexController extends Controller {
// 一旦开启三员 admin用户不能使用
if ("admin".equals(user.getUsername())) {
Integer userCount = Db.queryInt(Db.getSql("hasThreeMemberUsersCount"));
boolean isExistThreeMemberUsers = userCount == null ? false : (userCount > 0 ? true : false);
boolean isExistThreeMemberUsers = userCount != null && (userCount > 0);
if (isExistThreeMemberUsers) {
this.renderJson(Ret.fail("msg", "已开启三员管理,admin失效了。"));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:已开启三员管理", app);
return;
}
}
if (Integer.valueOf(user.getLocked()) == 1) {
if (user.getLocked() != null && Integer.parseInt(user.getLocked()) == 1) {
this.renderJson(Ret.fail("msg", "当前账户已被锁定"));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:该用户已被锁定", app);
return;
......@@ -163,19 +167,17 @@ public class IndexController extends Controller {
if (!password.equals(user.getPassword())) {
if (this.checkErrorCount(user)) {
this.renderJson(Ret.fail("msg", "您的错误次数已达5次以上,请稍后再试!"));
return;
} else {
int errorCount = permitLoginTimes - (user.getErrorcount() == null ? 0 : user.getErrorcount()) - 1;
if (user.getErrorcount() == 4) {
if (user.getErrorcount() !=null && user.getErrorcount() == 4) {
this.renderJson(Ret.fail("msg", "用户名或密码验证失败,您的账户于两小时后才可登录!"));
return;
} else {
this.renderJson(Ret.fail("msg", "用户名或密码验证失败,您还有" + errorCount + "次机会!"));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:密码验证错误",
app);
return;
}
}
return ;
}
Integer errorcount = user.getErrorcount();
if (errorcount != null && errorcount != 0) {
......@@ -197,7 +199,7 @@ public class IndexController extends Controller {
if (!"admin".equals(user.getUsername())) {
Integer noLockedRolesCount = Db.queryInt(Db.getSql("hasNoLockedRolesCount"), user.getUsername());
boolean noLockedRolesFlag = noLockedRolesCount == null ? false : (noLockedRolesCount.intValue() > 0 ? true : false);
boolean noLockedRolesFlag = noLockedRolesCount != null && (noLockedRolesCount > 0);
if (!noLockedRolesFlag) {
this.renderJson(Ret.fail("msg", "拥有的角色全部被锁定,不能登录系统了。"));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:该用户拥有的角色全部被锁定",
......@@ -205,7 +207,7 @@ public class IndexController extends Controller {
return;
}
}
System system = System.dao.template("getSystemPrivatekey", app).findFirst();
System system = InfoSystem.getSystem(app);
if (system == null) {
this.renderJson(Ret.fail("msg", "没有找到应用:" + app));
logService.saveAsLog("login", username, JwtInterceptor.getIpAddr(getRequest()), "登录失败,原因:没有找到应用" + app,
......@@ -294,6 +296,7 @@ public class IndexController extends Controller {
}
}
/**
* @Description: 验证密码强度
* @authorAndDate: ChengYaqing create on 2020/10/30 10:38
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment