2017-06-17 12:12:50 +00:00
|
|
|
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
|
2017-08-30 20:23:35 +00:00
|
|
|
if SiteConf.AdminPassword == pass {
|
2017-06-17 12:12:50 +00:00
|
|
|
sess.Set("login", true)
|
2017-08-31 20:49:55 +00:00
|
|
|
direct := c.QueryParam("direct")
|
|
|
|
if direct == "true" {
|
|
|
|
return c.Redirect(http.StatusSeeOther, "/admin")
|
|
|
|
}
|
2017-06-17 12:12:50 +00:00
|
|
|
return c.JSON(http.StatusOK, Message{"success"})
|
|
|
|
} else {
|
|
|
|
return c.JSON(http.StatusOK, Message{"fail"})
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|