Simplify homepage: remove auth check, keep login hidden for now
This commit is contained in:
@@ -6,10 +6,8 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/go-playground/validator/v10"
|
"github.com/go-playground/validator/v10"
|
||||||
jwtgo "github.com/golang-jwt/jwt"
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/echo/v4/middleware"
|
"github.com/labstack/echo/v4/middleware"
|
||||||
)
|
)
|
||||||
@@ -40,16 +38,7 @@ func main() {
|
|||||||
|
|
||||||
// Routes
|
// Routes
|
||||||
e.GET("/", func(c echo.Context) error {
|
e.GET("/", func(c echo.Context) error {
|
||||||
tokenString := getToken(c)
|
|
||||||
loggedIn := false
|
loggedIn := false
|
||||||
if tokenString != "" {
|
|
||||||
token, err := jwtgo.Parse(tokenString, func(token *jwtgo.Token) (interface{}, error) {
|
|
||||||
return []byte(cfg.JWTSecret), nil
|
|
||||||
})
|
|
||||||
if err == nil && token.Valid {
|
|
||||||
loggedIn = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
err := templates.Index(loggedIn).Render(c.Request().Context(), &buf)
|
err := templates.Index(loggedIn).Render(c.Request().Context(), &buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user