Rename session cookie
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
package webcontroller
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"fornaxian.tech/log"
|
|
||||||
"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 {
|
|
||||||
var api = wc.api.Login(key)
|
|
||||||
if err = api.DeleteUserSession(key); err != nil {
|
|
||||||
log.Warn("logout failed for session '%s': %s", key, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
http.Redirect(w, r, "/", http.StatusSeeOther)
|
|
||||||
}
|
|
||||||
@@ -256,7 +256,7 @@ func (wc *WebController) serveFile(path string) httprouter.Handle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (wc *WebController) getAPIKey(r *http.Request) (key string, err error) {
|
func (wc *WebController) getAPIKey(r *http.Request) (key string, err error) {
|
||||||
if cookie, err := r.Cookie("pd_auth_key"); err == nil {
|
if cookie, err := r.Cookie("nova_auth_key"); err == nil {
|
||||||
if len(cookie.Value) == 36 {
|
if len(cookie.Value) == 36 {
|
||||||
return cookie.Value, nil
|
return cookie.Value, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user