Redirect to the same page with flash message and retain user input #2150
Unanswered
wildfiremedia
asked this question in
Q&A
Replies: 1 comment
-
just render login page if username or password is not correct func login(c echo.Context) error {
femail := c.FormValue("email")
fpass := c.FormValue("password")
user := getUsername(femail) // User struct
if user.Pass == fpass && user.Email == femail {
// TODO save new session here
return c.Redirect(http.StatusSeeOther, "/") // 303 code
// or redirect to latest page
}
return c.Render(200, "login.html", "Username or password is wrong")
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Google isn't help and I couldn't find echo solution.
If a user were to type email and password into a login page and encounter an error when email or password is incorrect.
It would throw a flash message but also retain user email. I can wrote this in Go stdlib and response is Get.
But in Echo, the response is still Post.
return c.Render(http.StatusFound, "views/signin.html", echo.Map{"flashmessage": "Password..", "emailaddress": EmailAddress, "Csrf": helpers.NewCSRF(c)})
How do I redirect to the sign in page and retain user input with Get response instead of Post response?
Beta Was this translation helpful? Give feedback.
All reactions