| | |
| | | package com.tcm.training.admin.app.auth.service; |
| | | |
| | | import com.tcm.training.admin.app.auth.config.AppAuthProperties; |
| | | import com.tcm.training.admin.app.auth.support.StpAppUserUtil; |
| | | import cn.dev33.satoken.stp.SaTokenInfo; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Service |
| | | public class AppAuthSessionService { |
| | | |
| | | private final AppAuthProperties appAuthProperties; |
| | | |
| | | public AppAuthSessionService(AppAuthProperties appAuthProperties) { |
| | | this.appAuthProperties = appAuthProperties; |
| | | } |
| | | |
| | | /** |
| | | * 为指定 APP 用户建立登录态。 |
| | | */ |
| | | public void login(Long userId) { |
| | | StpAppUserUtil.login(userId); |
| | | StpAppUserUtil.login(userId, appAuthProperties.getTokenTimeoutSeconds()); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 获取当前请求携带的 APP token 值。 |
| | | */ |
| | | public String getTokenValue() { |
| | | return StpAppUserUtil.getTokenValue(); |
| | | } |
| | | |
| | | /** |
| | | * 注销当前 APP 登录态。 |
| | | */ |
| | | public void logout() { |