redirect to login page when user logout without token

This commit is contained in:
MaysWind
2023-04-16 02:00:59 +08:00
parent 221a7809b6
commit a96eb31dc9
6 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ func (a *TokensApi) TokenRevokeCurrentHandler(c *core.Context) (interface{}, *er
_, claims, err := a.tokens.ParseToken(c)
if err != nil {
return nil, errs.NewIncompleteOrIncorrectSubmissionError(err)
return nil, errs.Or(err, errs.NewIncompleteOrIncorrectSubmissionError(err))
}
uid, err := utils.StringToInt64(claims.Id)
+1
View File
@@ -18,4 +18,5 @@ var (
ErrInvalidUserTokenId = NewNormalError(NormalSubcategoryToken, 9, http.StatusBadRequest, "user token id is invalid")
ErrTokenRecordNotFound = NewNormalError(NormalSubcategoryToken, 10, http.StatusBadRequest, "token is not found")
ErrTokenExpired = NewNormalError(NormalSubcategoryToken, 11, http.StatusBadRequest, "token is expired")
ErrTokenIsEmpty = NewNormalError(NormalSubcategoryToken, 12, http.StatusBadRequest, "token is empty")
)
+4
View File
@@ -100,6 +100,10 @@ func (s *TokenService) ParseToken(c *core.Context) (*jwt.Token, *core.UserTokenC
}, request.WithClaims(claims))
if err != nil {
if err == request.ErrNoTokenInRequest {
return nil, nil, errs.ErrTokenIsEmpty
}
return nil, nil, err
}
+1
View File
@@ -47,6 +47,7 @@ axios.interceptors.response.use(response => {
|| errorCode === 202004 // current token type is invalid
|| errorCode === 202005 // current token requires two factor authorization
|| errorCode === 202006 // current token does not require two factor authorization
|| errorCode === 202012 // token is empty
) {
userState.clearTokenAndUserInfo(false);
location.reload();
+1
View File
@@ -547,6 +547,7 @@ export default {
'user token id is invalid': 'User token ID is invalid',
'token is not found': 'Token is not found',
'token is expired': 'Token is expired',
'token is empty': 'Token is empty',
'passcode is invalid': 'Passcode is invalid',
'two factor backup code is invalid': 'Two factor backup code is invalid',
'two factor is not enabled': 'Two factor is not enabled',
+1
View File
@@ -547,6 +547,7 @@ export default {
'user token id is invalid': '用户认证令牌ID无效',
'token is not found': '认证令牌不存在',
'token is expired': '认证令牌已过期',
'token is empty': '认证令牌为空',
'passcode is invalid': '验证码无效',
'two factor backup code is invalid': '两步验证备用码无效',
'two factor is not enabled': '两步验证没有启用',