2018-06-20 23:47:47 +02:00
|
|
|
package webcontroller
|
2018-06-23 21:17:53 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"fornaxian.com/pixeldrain-web/pixelapi"
|
|
|
|
"github.com/Fornaxian/log"
|
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
2018-09-19 22:26:52 +02:00
|
|
|
func (wc *WebController) serveRegister(
|
|
|
|
w http.ResponseWriter,
|
|
|
|
r *http.Request,
|
|
|
|
p httprouter.Params,
|
|
|
|
) {
|
|
|
|
var tpld = wc.newTemplateData(w, r)
|
2019-03-28 10:47:27 +01:00
|
|
|
tpld.Other = wc.captchaKey()
|
2018-09-19 22:26:52 +02:00
|
|
|
|
|
|
|
err := wc.templates.Get().ExecuteTemplate(w, "register", tpld)
|
|
|
|
if err != nil {
|
|
|
|
log.Error("Error executing template '%s': %s", "register", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-23 21:17:53 +02:00
|
|
|
func (wc *WebController) serveLogout(
|
|
|
|
w http.ResponseWriter,
|
|
|
|
r *http.Request,
|
|
|
|
p httprouter.Params,
|
|
|
|
) {
|
|
|
|
if key, err := wc.getAPIKey(r); err == nil {
|
|
|
|
var api = pixelapi.New(wc.conf.APIURLInternal, key)
|
|
|
|
_, err1 := api.UserSessionDestroy(key)
|
|
|
|
if err1 != nil {
|
|
|
|
log.Warn("logout failed for session '%s': %s", key, err1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-08 14:47:51 +02:00
|
|
|
http.Redirect(w, r, "/", http.StatusSeeOther)
|
2018-07-08 14:40:20 +02:00
|
|
|
}
|