23 lines
532 B
Go
23 lines
532 B
Go
package routing
|
|
|
|
import (
|
|
"net/http"
|
|
)
|
|
|
|
func (ctx *Context) LogoutPost(w http.ResponseWriter, r *http.Request) {
|
|
session, err := ctx.store.Get(r, "lishwist_user")
|
|
if err != nil {
|
|
http.Error(w, "Something went wrong. Error code: Iroh", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
session.Options.MaxAge = 0
|
|
session.Values = nil
|
|
if err := session.Save(r, w); err != nil {
|
|
http.Error(w, "Something went wrong. Error code: Azula", http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
|
}
|