2019-11-28 11:50:51 +01:00
|
|
|
package route
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2019-11-28 12:13:01 +01:00
|
|
|
"forge.cadoles.com/wpetit/gitea-kan/internal/config"
|
2019-11-28 11:50:51 +01:00
|
|
|
"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())
|
|
|
|
conf := config.Must(ctn)
|
|
|
|
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"))
|
|
|
|
}
|
|
|
|
http.Redirect(w, r, conf.Gitea.LogoutURL, http.StatusSeeOther)
|
|
|
|
}
|