File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package handlers
22
33import (
44 "net/http"
5+ "strings"
56
67 "github.com/authorizerdev/authorizer/server/cookie"
78 "github.com/authorizerdev/authorizer/server/crypto"
@@ -12,6 +13,7 @@ import (
1213// Handler to logout user
1314func LogoutHandler () gin.HandlerFunc {
1415 return func (gc * gin.Context ) {
16+ redirectURL := strings .TrimSpace (gc .Query ("redirect_url" ))
1517 // get fingerprint hash
1618 fingerprintHash , err := cookie .GetSession (gc )
1719 if err != nil {
@@ -34,8 +36,12 @@ func LogoutHandler() gin.HandlerFunc {
3436 sessionstore .RemoveState (fingerPrint )
3537 cookie .DeleteSession (gc )
3638
37- gc .JSON (http .StatusOK , gin.H {
38- "message" : "Logged out successfully" ,
39- })
39+ if redirectURL != "" {
40+ gc .Redirect (http .StatusPermanentRedirect , redirectURL )
41+ } else {
42+ gc .JSON (http .StatusOK , gin.H {
43+ "message" : "Logged out successfully" ,
44+ })
45+ }
4046 }
4147}
You can’t perform that action at this time.
0 commit comments