Skip to content

Commit 2a65723

Browse files
committed
添加会话异常
1 parent 81886d1 commit 2a65723

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

exception/code.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ package exception
33
import "net/http"
44

55
const (
6-
// AccessTokenIllegal 访问token不合法
7-
AccessTokenIllegal = 50008
8-
// RefreshTokenIllegal 刷新token不合法
9-
RefreshTokenIllegal = 50009
10-
// OtherClientsLoggedIn 启动端登录
6+
// OtherPlaceLoggedIn 登录登录
7+
OtherPlaceLoggedIn = 50010
8+
// OtherIPLoggedIn 异常IP登录
9+
OtherIPLoggedIn = 50011
10+
// OtherClientsLoggedIn 用户已经通过其他端登录
1111
OtherClientsLoggedIn = 50012
12+
// SessionTerminated 会话中断
13+
SessionTerminated = 50013
1214
// AccessTokenExpired token过期
1315
AccessTokenExpired = 50014
1416
// RefreshTokenExpired token过期
1517
RefreshTokenExpired = 50015
18+
// AccessTokenIllegal 访问token不合法
19+
AccessTokenIllegal = 50016
20+
// RefreshTokenIllegal 刷新token不合法
21+
RefreshTokenIllegal = 50017
1622

1723
// Unauthorized 未认证
1824
Unauthorized = http.StatusUnauthorized
@@ -42,7 +48,10 @@ var (
4248
UnKnownException: "未知异常",
4349
AccessTokenIllegal: "访问令牌不合法",
4450
RefreshTokenIllegal: "刷新令牌不合法",
51+
OtherPlaceLoggedIn: "异地登录",
52+
OtherIPLoggedIn: "异常IP登录",
4553
OtherClientsLoggedIn: "用户已经通过其他端登录",
54+
SessionTerminated: "会话结束",
4655
AccessTokenExpired: "访问过期, 请刷新",
4756
RefreshTokenExpired: "刷新过期, 请登录",
4857
}

exception/exception.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,26 @@ func NewRefreshTokenIllegal(format string, a ...interface{}) APIException {
3838
return newException(usedNamespace, RefreshTokenIllegal, format, a...)
3939
}
4040

41-
// NewOtherClientsLoggedIn 访问token过期
41+
// NewOtherClientsLoggedIn 其他端登录
4242
func NewOtherClientsLoggedIn(format string, a ...interface{}) APIException {
4343
return newException(usedNamespace, OtherClientsLoggedIn, format, a...)
4444
}
4545

46+
// NewOtherPlaceLoggedIn 异地登录
47+
func NewOtherPlaceLoggedIn(format string, a ...interface{}) APIException {
48+
return newException(usedNamespace, OtherPlaceLoggedIn, format, a...)
49+
}
50+
51+
// NewOtherIPLoggedIn 异常IP登录
52+
func NewOtherIPLoggedIn(format string, a ...interface{}) APIException {
53+
return newException(usedNamespace, OtherIPLoggedIn, format, a...)
54+
}
55+
56+
// NewSessionTerminated 会话结束
57+
func NewSessionTerminated(format string, a ...interface{}) APIException {
58+
return newException(usedNamespace, SessionTerminated, format, a...)
59+
}
60+
4661
// NewAccessTokenExpired 访问token过期
4762
func NewAccessTokenExpired(format string, a ...interface{}) APIException {
4863
return newException(usedNamespace, AccessTokenExpired, format, a...)

0 commit comments

Comments
 (0)