Skip to content

Commit

Permalink
StpUtil.getTokenSession() 时若未提供 token 将直接抛出异常
Browse files Browse the repository at this point in the history
  • Loading branch information
click33 committed May 12, 2024
1 parent 43c9452 commit 8f467bb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public interface SaErrorCode {
/** 获取 SaSession 时提供的 SessionId 为空 */
int CODE_11072 = 11072;

/** 获取 Token-Session 时提供的 token 为空 */
int CODE_11073 = 11073;


// ------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1296,7 +1296,7 @@ public SaSession getSession() {
*/
public SaSession getTokenSessionByToken(String tokenValue, boolean isCreate) {
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 -> {
// 这里是该 Token-Session 首次创建时才会被执行的方法:
Expand Down Expand Up @@ -1333,7 +1333,7 @@ public SaSession getTokenSession(boolean isCreate) {
// 2、如果前端根本没有提供 Token ,则直接返回 null
String tokenValue = getTokenValue();
if(SaFoxUtil.isEmpty(tokenValue)) {
return null;
throw new SaTokenException("Token-Session 获取失败:token 为空").setCode(SaErrorCode.CODE_11073);
}

// 3、代码至此:tokenSessionCheckLogin 校验通过、且 Token 有值
Expand Down

0 comments on commit 8f467bb

Please sign in to comment.