28 lines
567 B
Go
28 lines
567 B
Go
package route
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
oidc "forge.cadoles.com/wpetit/goweb-oidc"
|
|
"github.com/pkg/errors"
|
|
"gitlab.com/wpetit/goweb/middleware/container"
|
|
"gitlab.com/wpetit/goweb/service/session"
|
|
)
|
|
|
|
func handleLogout(w http.ResponseWriter, r *http.Request) {
|
|
ctn := container.Must(r.Context())
|
|
|
|
sess, err := session.Must(ctn).Get(w, r)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not retrieve session"))
|
|
}
|
|
|
|
if err := sess.Delete(w, r); err != nil {
|
|
panic(errors.Wrap(err, "could not delete session"))
|
|
}
|
|
|
|
client := oidc.Must(ctn)
|
|
|
|
client.Logout(w, r)
|
|
}
|