Konfi-Castle-Kasino/login.go

32 lines
613 B
Go

package main
import (
"github.com/labstack/echo"
"net/http"
)
func login(c echo.Context) error {
rw := c.Response()
r := c.Request()
//Session init
sess := GlobalSessions.SessionStart(rw, r)
//Config
SiteConf := initConfig()
var pass string = c.FormValue("password")
//Wenn das password stimmt, einloggen
if SiteConf.AdminPassword == pass {
sess.Set("login", true)
direct := c.QueryParam("direct")
if direct == "true" {
return c.Redirect(http.StatusSeeOther, "/admin")
}
return c.JSON(http.StatusOK, Message{"success"})
} else {
return c.JSON(http.StatusOK, Message{"fail"})
}
}