From 9d4c4dba65081c46cb2de7398deea3797609636a Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Wed, 29 Apr 2026 23:01:58 -0500 Subject: [PATCH] up --- resources/views/auth/login.html | 9 +++++++++ resources/views/layouts/landing.html | 24 ++++++++++-------------- rest/controllers/auth_controller.go | 3 +++ rest/middlewares/login.go | 17 ++++------------- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/resources/views/auth/login.html b/resources/views/auth/login.html index c7225f9..edb59c0 100755 --- a/resources/views/auth/login.html +++ b/resources/views/auth/login.html @@ -1,4 +1,13 @@
+ + {{if .error}} +
+ + + + {{.error}} +
+ {{end}}
diff --git a/resources/views/layouts/landing.html b/resources/views/layouts/landing.html index d641854..9570276 100755 --- a/resources/views/layouts/landing.html +++ b/resources/views/layouts/landing.html @@ -6,25 +6,21 @@ U-site - - + + + + - - - - - -
-
- {{embed}} -
+ +
+ {{embed}}
diff --git a/rest/controllers/auth_controller.go b/rest/controllers/auth_controller.go index d360e51..35a4f5f 100755 --- a/rest/controllers/auth_controller.go +++ b/rest/controllers/auth_controller.go @@ -15,6 +15,9 @@ import ( func LoginGet(c *fiber.Ctx) error { data := getFlashData(c) data["title"] = "Login | " + if errMsg := c.Query("error"); errMsg != "" { + data["error"] = errMsg + } return c.Render("auth/login", data, "layouts/landing") } diff --git a/rest/middlewares/login.go b/rest/middlewares/login.go index dc64705..574ec4f 100755 --- a/rest/middlewares/login.go +++ b/rest/middlewares/login.go @@ -5,6 +5,7 @@ import ( "github.com/gookit/validate" "github.com/sujit-baniya/fiber-boilerplate/pkg/auth" "github.com/sujit-baniya/fiber-boilerplate/pkg/models" + "net/url" ) func RedirectToHomePageOnLogin(c *fiber.Ctx) error { @@ -17,26 +18,16 @@ func RedirectToHomePageOnLogin(c *fiber.Ctx) error { func ValidateLoginPost(c *fiber.Ctx) error { var login models.Login if err := c.BodyParser(&login); err != nil { - return c.JSON(fiber.Map{ - "status": "error", - "message": err.Error(), - }) + return c.Redirect("/login?error=" + url.QueryEscape(err.Error())) } v := validate.Struct(login) if !v.Validate() { - return c.JSON(fiber.Map{ - "status": "error", - "message": v.Errors.One(), - }) + return c.Redirect("/login?error=" + url.QueryEscape(v.Errors.One())) } user, err := login.CheckLogin() - if err != nil { - return c.JSON(fiber.Map{ - "status": "error", - "message": err.Error(), - }) + return c.Redirect("/login?error=" + url.QueryEscape(err.Error())) } c.Locals("user", user)