refactor(web): make a separate auth middlewares for server

also slightly change api auth middleware
This commit is contained in:
2025-01-07 04:32:49 +03:00
parent 8b417dc623
commit 2228dc5f14
4 changed files with 20 additions and 10 deletions
+3 -8
View File
@@ -7,8 +7,8 @@ import (
)
func root(c *gin.Context) {
authorized := c.GetBool("authorized")
if authorized {
user_id := c.GetString("user_id")
if user_id != "" {
c.Redirect(http.StatusSeeOther, "/quotes")
} else {
c.HTML(http.StatusOK, "auth.html", nil)
@@ -16,10 +16,5 @@ func root(c *gin.Context) {
}
func quotes(c *gin.Context) {
authorized := c.GetBool("authorized")
if authorized {
c.HTML(http.StatusOK, "quotes.html", nil)
} else {
c.Redirect(http.StatusSeeOther, "/")
}
c.HTML(http.StatusOK, "quotes.html", nil)
}