2018-06-20 23:47:47 +02:00
|
|
|
package webcontroller
|
2018-06-23 21:17:53 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2021-11-16 15:20:15 +01:00
|
|
|
"fornaxian.tech/log"
|
2018-06-23 21:17:53 +02:00
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (wc *WebController) serveLogout(
|
|
|
|
w http.ResponseWriter,
|
|
|
|
r *http.Request,
|
|
|
|
p httprouter.Params,
|
|
|
|
) {
|
|
|
|
if key, err := wc.getAPIKey(r); err == nil {
|
2021-01-05 00:00:46 +01:00
|
|
|
var api = wc.api.Login(key)
|
2021-03-10 20:13:32 +01:00
|
|
|
if err = api.DeleteUserSession(key); err != nil {
|
2019-12-17 19:28:30 +01:00
|
|
|
log.Warn("logout failed for session '%s': %s", key, err)
|
2018-06-23 21:17:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 14:47:51 +02:00
|
|
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
2018-07-08 14:40:20 +02:00
|
|
|
}
|