Skip to content

Commit

Permalink
fix: clear activated cookie when logout
Browse files Browse the repository at this point in the history
  • Loading branch information
Aylie Chou committed Apr 18, 2024
1 parent d5442d6 commit b74b39d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions controllers/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,12 +334,13 @@ func (mc *MembershipController) TokenDispatch(c *gin.Context) (int, gin.H, error
}}, nil
}

// TokenInvalidate deletes the id_token stored in the client side
// TokenInvalidate deletes the id_token & activated stored in the client side
func (mc *MembershipController) TokenInvalidate(c *gin.Context) {
const signInPage = "https://accounts.twreporter.org/signin"
var defaultDomain = globals.Conf.App.Domain

cookieName := "id_token"
cookieName1 := "id_token"
cookieName2 := "activated"
invalidateExp := -1

destination := c.Query("destination")
Expand All @@ -355,7 +356,8 @@ func (mc *MembershipController) TokenInvalidate(c *gin.Context) {
u, _ = url.Parse(destination)
}

c.SetCookie(cookieName, "", invalidateExp, defaultPath, defaultDomain, u.Scheme == "https", true)
c.SetCookie(cookieName1, "", invalidateExp, defaultPath, defaultDomain, u.Scheme == "https", true)
c.SetCookie(cookieName2, "", invalidateExp, defaultPath, defaultDomain, u.Scheme == "https", true)
c.Redirect(http.StatusTemporaryRedirect, destination)
}

Expand Down

0 comments on commit b74b39d

Please sign in to comment.