Skip to content
This repository was archived by the owner on Nov 11, 2024. It is now read-only.

Commit 5969f74

Browse files
committed
modify example code
1 parent 1204dfb commit 5969f74

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

example/api/auth.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func init() {
3232
Authenticator: Authenticator,
3333
LoginResponse: LoginResponse,
3434
RefreshResponse: RefreshResponse,
35+
LogoutResponse: LogoutResponse,
3536
Unauthorized: Unauthorized,
3637
IdentityHandler: IdentityHandler,
3738
PayloadFunc: PayloadFunc,
@@ -94,12 +95,21 @@ func RefreshResponse(r *ghttp.Request, code int, token string, expire time.Time)
9495
r.ExitAll()
9596
}
9697

98+
// LogoutResponse is used to set token blacklist.
99+
func LogoutResponse(r *ghttp.Request, code int) {
100+
r.Response.WriteJson(g.Map{
101+
"code": code,
102+
"message": "success",
103+
})
104+
r.ExitAll()
105+
}
106+
97107
// Authenticator is used to validate login parameters.
98108
// It must return user data as user identifier, it will be stored in Claim Array.
99109
// Check error (e) to determine the appropriate error message.
100110
func Authenticator(r *ghttp.Request) (interface{}, error) {
101111
var (
102-
apiReq *model.ApiLoginReq
112+
apiReq *model.ApiLoginReq
103113
serviceReq *model.ServiceLoginReq
104114
)
105115
if err := r.Parse(&apiReq); err != nil {

0 commit comments

Comments
 (0)