mirror of
https://github.com/rjNemo/rentease.git
synced 2026-06-10 04:36:50 +00:00
32 lines
766 B
Go
32 lines
766 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func handleLoginPage() echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
return c.String(http.StatusOK, "ok")
|
|
}
|
|
}
|
|
|
|
func handleLogin() echo.HandlerFunc {
|
|
return func(c echo.Context) error {
|
|
email := c.FormValue("email")
|
|
_ = c.FormValue("password")
|
|
|
|
//user, err := s.us.SignIn(email, pwd)
|
|
user := struct{ Id int }{Id: 1}
|
|
var err error = nil
|
|
if err != nil {
|
|
return c.Redirect(http.StatusSeeOther, fmt.Sprintf("%s?err=invalid+credentials", "/login"))
|
|
}
|
|
if err = writeCookie(c, user.Id, email); err != nil {
|
|
return c.Redirect(http.StatusSeeOther, fmt.Sprintf("%s?err=invalid+credentials", "/login"))
|
|
}
|
|
return c.Redirect(http.StatusFound, "/bookings")
|
|
}
|
|
}
|