1
0
mirror of https://github.com/volatiletech/authboss.git synced 2025-09-16 09:06:20 +02:00

Add logout events

This commit is contained in:
Abel Kuruvilla
2019-10-21 01:53:36 +05:30
parent 4d85b23e8a
commit 8c7bb388ad
2 changed files with 16 additions and 0 deletions

View File

@@ -28,6 +28,7 @@ const (
EventGetUser
EventGetUserSession
EventPasswordReset
EventLogout
)
// EventHandler reacts to events that are fired by Authboss controllers.

View File

@@ -49,10 +49,25 @@ func (l *Logout) Logout(w http.ResponseWriter, r *http.Request) error {
logger.Info("user (unknown) logged out")
}
var handled bool
handled, err = l.Events.FireBefore(authboss.EventLogout, w, r)
if err != nil {
return err
} else if handled {
return nil
}
authboss.DelAllSession(w, l.Config.Storage.SessionStateWhitelistKeys)
authboss.DelKnownSession(w)
authboss.DelKnownCookie(w)
handled, err = l.Authboss.Events.FireAfter(authboss.EventLogout, w, r)
if err != nil {
return err
} else if handled {
return nil
}
ro := authboss.RedirectOptions{
Code: http.StatusTemporaryRedirect,
RedirectPath: l.Authboss.Paths.LogoutOK,