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:
@@ -28,6 +28,7 @@ const (
|
||||
EventGetUser
|
||||
EventGetUserSession
|
||||
EventPasswordReset
|
||||
EventLogout
|
||||
)
|
||||
|
||||
// EventHandler reacts to events that are fired by Authboss controllers.
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user