|
|
@ -25,6 +25,7 @@ import org.opsli.api.wrapper.system.tenant.TenantModel;
|
|
|
|
import org.opsli.api.wrapper.system.user.UserModel;
|
|
|
|
import org.opsli.api.wrapper.system.user.UserModel;
|
|
|
|
import org.opsli.common.api.TokenThreadLocal;
|
|
|
|
import org.opsli.common.api.TokenThreadLocal;
|
|
|
|
import org.opsli.common.exception.TokenException;
|
|
|
|
import org.opsli.common.exception.TokenException;
|
|
|
|
|
|
|
|
import org.opsli.common.thread.refuse.AsyncProcessQueueReFuse;
|
|
|
|
import org.opsli.common.utils.IPUtil;
|
|
|
|
import org.opsli.common.utils.IPUtil;
|
|
|
|
import org.opsli.core.msg.TokenMsg;
|
|
|
|
import org.opsli.core.msg.TokenMsg;
|
|
|
|
import org.opsli.core.security.shiro.realm.OAuth2Realm;
|
|
|
|
import org.opsli.core.security.shiro.realm.OAuth2Realm;
|
|
|
@ -122,6 +123,8 @@ public class LoginRestController {
|
|
|
|
//生成token,并保存到Redis
|
|
|
|
//生成token,并保存到Redis
|
|
|
|
ResultVo<Map<String, Object>> resultVo = UserTokenUtil.createToken(user);
|
|
|
|
ResultVo<Map<String, Object>> resultVo = UserTokenUtil.createToken(user);
|
|
|
|
if(resultVo.isSuccess()){
|
|
|
|
if(resultVo.isSuccess()){
|
|
|
|
|
|
|
|
// 异步保存IP
|
|
|
|
|
|
|
|
AsyncProcessQueueReFuse.execute(()->{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 临时设置 token缓存
|
|
|
|
// 临时设置 token缓存
|
|
|
|
TokenThreadLocal.put(String.valueOf(resultVo.getData().get("token")));
|
|
|
|
TokenThreadLocal.put(String.valueOf(resultVo.getData().get("token")));
|
|
|
@ -129,13 +132,12 @@ public class LoginRestController {
|
|
|
|
String clientIpAddress = IPUtil.getClientIpAddress(request);
|
|
|
|
String clientIpAddress = IPUtil.getClientIpAddress(request);
|
|
|
|
user.setLoginIp(clientIpAddress);
|
|
|
|
user.setLoginIp(clientIpAddress);
|
|
|
|
iUserService.updateLoginIp(user);
|
|
|
|
iUserService.updateLoginIp(user);
|
|
|
|
}catch (Exception ignored){
|
|
|
|
|
|
|
|
}finally {
|
|
|
|
}finally {
|
|
|
|
// 清空 token缓存
|
|
|
|
// 清空 token缓存
|
|
|
|
TokenThreadLocal.remove();
|
|
|
|
TokenThreadLocal.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return resultVo;
|
|
|
|
return resultVo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|