Oops
This commit is contained in:
parent
96b766f47b
commit
8382c7fb86
1 changed files with 16 additions and 1 deletions
17
lib/user.go
17
lib/user.go
|
@ -75,7 +75,7 @@ func SaveUser(dbPool *pgxpool.Pool, user *User) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func AuthenticatedMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
func AuthenticatedPageMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
isSignedIn := IsSignedIn(c)
|
isSignedIn := IsSignedIn(c)
|
||||||
|
|
||||||
|
@ -89,3 +89,18 @@ func AuthenticatedMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func AuthenticatedEndpointMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
isSignedIn := IsSignedIn(c)
|
||||||
|
|
||||||
|
// Check if user is authenticated
|
||||||
|
if !isSignedIn {
|
||||||
|
// Return 401 if not authenticated
|
||||||
|
return c.String(http.StatusUnauthorized, "Unauthorized")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Proceed with the request if authenticated
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue