mirror of
https://gitee.com/dromara/sa-token.git
synced 2025-05-05 05:07:54 +08:00
StpUtil.getTokenSession() 时若未提供 token 将直接抛出异常
This commit is contained in:
parent
43c9452fb2
commit
8f467bbc9c
@ -125,6 +125,9 @@ public interface SaErrorCode {
|
|||||||
/** 获取 SaSession 时提供的 SessionId 为空 */
|
/** 获取 SaSession 时提供的 SessionId 为空 */
|
||||||
int CODE_11072 = 11072;
|
int CODE_11072 = 11072;
|
||||||
|
|
||||||
|
/** 获取 Token-Session 时提供的 token 为空 */
|
||||||
|
int CODE_11073 = 11073;
|
||||||
|
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
|
|
||||||
|
@ -1296,7 +1296,7 @@ public class StpLogic {
|
|||||||
*/
|
*/
|
||||||
public SaSession getTokenSessionByToken(String tokenValue, boolean isCreate) {
|
public SaSession getTokenSessionByToken(String tokenValue, boolean isCreate) {
|
||||||
if(SaFoxUtil.isEmpty(tokenValue)) {
|
if(SaFoxUtil.isEmpty(tokenValue)) {
|
||||||
throw new SaTokenException("Token-Session 获取失败:token 不能为空");
|
throw new SaTokenException("Token-Session 获取失败:token 为空").setCode(SaErrorCode.CODE_11073);
|
||||||
}
|
}
|
||||||
return getSessionBySessionId(splicingKeyTokenSession(tokenValue), isCreate, null, session -> {
|
return getSessionBySessionId(splicingKeyTokenSession(tokenValue), isCreate, null, session -> {
|
||||||
// 这里是该 Token-Session 首次创建时才会被执行的方法:
|
// 这里是该 Token-Session 首次创建时才会被执行的方法:
|
||||||
@ -1333,7 +1333,7 @@ public class StpLogic {
|
|||||||
// 2、如果前端根本没有提供 Token ,则直接返回 null
|
// 2、如果前端根本没有提供 Token ,则直接返回 null
|
||||||
String tokenValue = getTokenValue();
|
String tokenValue = getTokenValue();
|
||||||
if(SaFoxUtil.isEmpty(tokenValue)) {
|
if(SaFoxUtil.isEmpty(tokenValue)) {
|
||||||
return null;
|
throw new SaTokenException("Token-Session 获取失败:token 为空").setCode(SaErrorCode.CODE_11073);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3、代码至此:tokenSessionCheckLogin 校验通过、且 Token 有值
|
// 3、代码至此:tokenSessionCheckLogin 校验通过、且 Token 有值
|
||||||
|
Loading…
Reference in New Issue
Block a user