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)
		return c.JSON(http.StatusOK, Message{"success"})
	} else {
		return c.JSON(http.StatusOK, Message{"fail"})
	}

}
