mirror of https://gitee.com/stylefeng/roses
【7.2.5】【auth】更新刷新用户session信息的接口
parent
644bc7a94a
commit
b42aecf521
|
@ -28,6 +28,7 @@ import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
|||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginRequest;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginResponse;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.auth.LoginWithTokenRequest;
|
||||
import cn.stylefeng.roses.kernel.auth.api.pojo.login.LoginUser;
|
||||
import cn.stylefeng.roses.kernel.jwt.api.pojo.payload.DefaultJwtPayload;
|
||||
|
||||
/**
|
||||
|
@ -123,4 +124,16 @@ public interface AuthServiceApi {
|
|||
* @date 2022/1/22 16:37
|
||||
*/
|
||||
void cancelFreeze(LoginRequest loginRequest);
|
||||
|
||||
/**
|
||||
* 为指定token创建新的登录信息
|
||||
*
|
||||
* @param token 用户旧的token
|
||||
* @param account 用户账号
|
||||
* @return 新的当前登录用户
|
||||
* @author fengshuonan
|
||||
* @date 2022/10/17 0:04
|
||||
*/
|
||||
LoginUser createNewLoginInfo(String token, String account);
|
||||
|
||||
}
|
||||
|
|
|
@ -268,6 +268,18 @@ public class AuthServiceImpl implements AuthServiceApi {
|
|||
loginErrorCountCacheApi.remove(loginRequest.getAccount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginUser createNewLoginInfo(String token, String account) {
|
||||
|
||||
// 获取用户的信息
|
||||
UserLoginInfoDTO userLoginInfo = userServiceApi.getUserLoginInfo(account);
|
||||
|
||||
// 创建用户会话信息
|
||||
sessionManagerApi.updateSession(token, userLoginInfo.getLoginUser());
|
||||
|
||||
return userLoginInfo.getLoginUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录的真正业务逻辑
|
||||
*
|
||||
|
|
|
@ -26,6 +26,8 @@ package cn.stylefeng.roses.kernel.auth.session;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.SessionManagerApi;
|
||||
import cn.stylefeng.roses.kernel.auth.api.cookie.SessionCookieCreator;
|
||||
import cn.stylefeng.roses.kernel.auth.api.expander.AuthConfigExpander;
|
||||
|
@ -109,13 +111,9 @@ public class DefaultSessionManager implements SessionManagerApi {
|
|||
|
||||
@Override
|
||||
public void updateSession(String token, LoginUser loginUser) {
|
||||
LoginUser session = this.getSession(token);
|
||||
|
||||
// 该用户session为空不能更新
|
||||
if (session == null) {
|
||||
if (StrUtil.isEmpty(token) || ObjectUtil.isEmpty(loginUser)) {
|
||||
return;
|
||||
}
|
||||
|
||||
loginUserCache.put(token, loginUser, sessionExpiredSeconds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue