mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-06-28 13:34:18 +08:00
优化:前端未提供 Token 时,getTokenSession() 将抛出未登录异常,而不是返回 null。
This commit is contained in:
parent
47e11f0c83
commit
2629b791d2
@ -951,16 +951,20 @@ public class StpLogic {
|
||||
* @return Session对象
|
||||
*/
|
||||
public SaSession getTokenSession(boolean isCreate) {
|
||||
// Token 为空的情况下直接返回 null
|
||||
|
||||
// 如果配置了:tokenSessionCheckLogin == true,则需要先校验当前是否登录
|
||||
if(getConfig().getTokenSessionCheckLogin()) {
|
||||
checkLogin();
|
||||
}
|
||||
|
||||
// 如果前端没有提供 Token ,则直接返回 null
|
||||
String tokenValue = getTokenValue();
|
||||
if(SaFoxUtil.isEmpty(tokenValue)) {
|
||||
return null;
|
||||
}
|
||||
// 如果配置了需要校验登录状态,则验证一下
|
||||
if(getConfig().getTokenSessionCheckLogin()) {
|
||||
checkLogin();
|
||||
}
|
||||
// 获取 SaSession 数据
|
||||
|
||||
// 代码至此:tokenSessionCheckLogin 校验通过、且 Token 有值
|
||||
// 现在根据前端提供的 Token 获取它对应的 Token-Session 对象(SaSession)
|
||||
return getTokenSessionByToken(tokenValue, isCreate);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user