security loginuser

This commit is contained in:
sxu 2025-02-13 12:28:32 +08:00
parent f9cc1fb291
commit 45c1291aa5
3 changed files with 9 additions and 12 deletions

View File

@ -105,8 +105,6 @@ public class TokenController {
LoginUser loginUser = custLogin(form); LoginUser loginUser = custLogin(form);
Map<String, Object> map = tokenService.createToken(loginUser); Map<String, Object> map = tokenService.createToken(loginUser);
loginUser.setToken((String) map.get(CustTokenService.ACCESS_TOKEN)); loginUser.setToken((String) map.get(CustTokenService.ACCESS_TOKEN));
loginUser.setExpireIn((Long) map.get(CustTokenService.EXPIRES_IN));
loginUser.setLogin((boolean) map.get(CustTokenService.IS_LOGIN));
return R.ok(loginUser); return R.ok(loginUser);
} }
@ -141,10 +139,9 @@ public class TokenController {
if (Objects.isNull(result)) { if (Objects.isNull(result)) {
throw new ServiceException("未找到用户"); throw new ServiceException("未找到用户");
} else { } else {
result.setCustIdStr(result.getCustId().toString());
if (CustLoginTypeEnum.getNeedPasswordLoginTypeToMap().containsKey(content.getLoginType())) { if (CustLoginTypeEnum.getNeedPasswordLoginTypeToMap().containsKey(content.getLoginType())) {
content.setPassword(AesEncryptUtil.aesDecode(content.getPassword())); content.setPassword(AesEncryptUtil.aesDecode(content.getPassword()));
if (!encoder.matches(content.getPassword(), result.getPwd())) { if (!encoder.matches(content.getPassword(), result.getPassword())) {
throw new ServiceException("密码错误"); throw new ServiceException("密码错误");
} }
} }
@ -167,9 +164,9 @@ public class TokenController {
CustCasual insertCasual = new CustCasual(); CustCasual insertCasual = new CustCasual();
openid = IdUtil.simpleUUID(); openid = IdUtil.simpleUUID();
insertCasual.setCasualId(Id.next()); //TODO, NPE insertCasual.setCasualId(Id.next()); //TODO, NPE
insertCasual.setCasualName(SM4EncryptUtils.sm4Decrypt(result.getCustName())); insertCasual.setCasualName(SM4EncryptUtils.sm4Decrypt(result.getNickName()));
insertCasual.setCustId(result.getCustId()); insertCasual.setCustId(result.getCustId());
insertCasual.setMobile(SM4EncryptUtils.sm4Decrypt(result.getMobile())); insertCasual.setMobile(SM4EncryptUtils.sm4Decrypt(result.getPhonenumber()));
insertCasual.setOpenid(openid); insertCasual.setOpenid(openid);
insertCasual.setSourceType(sourceType); insertCasual.setSourceType(sourceType);
this.authCustCasualMapper.addCustCasual(insertCasual); this.authCustCasualMapper.addCustCasual(insertCasual);
@ -181,9 +178,9 @@ public class TokenController {
} }
} }
result.setOpenid(openid); result.setOpenId(openid);
result.setCustName(SM4EncryptUtils.sm4Decrypt(result.getCustName())); result.setNickName(SM4EncryptUtils.sm4Decrypt(result.getNickName()));
result.setMobile(SM4EncryptUtils.sm4Decrypt(result.getMobile())); result.setPhonenumber(SM4EncryptUtils.sm4Decrypt(result.getPhonenumber()));
return result; return result;
} }

View File

@ -74,10 +74,10 @@ public class CustTokenService {
delExistingToken(loginUser.getCustId()); delExistingToken(loginUser.getCustId());
String token = IdUtils.fastUUID(); String token = IdUtils.fastUUID();
Long custId = loginUser.getCustId(); Long custId = loginUser.getCustId();
String userName = loginUser.getCustName(); String userName = loginUser.getNickName();
loginUser.setToken(token); loginUser.setToken(token);
loginUser.setCustId(custId); loginUser.setCustId(custId);
loginUser.setCustName(userName); loginUser.setNickName(userName);
loginUser.setIpaddr(IpUtils.getIpAddr()); loginUser.setIpaddr(IpUtils.getIpAddr());
refreshToken(loginUser); refreshToken(loginUser);
// Jwt存储信息 // Jwt存储信息

View File

@ -3,7 +3,7 @@
<mapper namespace="com.bonus.auth.mapper.AuthCustInfoMapper"> <mapper namespace="com.bonus.auth.mapper.AuthCustInfoMapper">
<!--根据人员id集合获取人员信息--> <!--根据人员id集合获取人员信息-->
<select id="selectLoginInfo" resultType="com.bonus.system.api.model.LoginUser"> <select id="selectLoginInfo" resultType="com.bonus.system.api.model.LoginUser">
select cust_id, cust_name, cust_num, cust_photo_url, mobile, pwd select cust_id as custId, open_id as openId, cust_name as nickName, cust_photo_url as photoUrl, mobile as phonenumber, pwd as password
from cust_info from cust_info
<where> <where>
cust_state = 1 and (psn_type != 999 or psn_type is null) cust_state = 1 and (psn_type != 999 or psn_type is null)