2024-12-16 15:29:54 -05:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/labstack/echo/v4"
|
|
|
|
|
"github.com/onsonr/sonr/pkg/gateway/middleware"
|
|
|
|
|
)
|
|
|
|
|
|
2024-12-18 15:53:45 -05:00
|
|
|
func HandleIndex(c echo.Context) error {
|
|
|
|
|
id := middleware.GetSessionID(c)
|
|
|
|
|
if id == "" {
|
|
|
|
|
return startNewSession(c)
|
|
|
|
|
}
|
|
|
|
|
return middleware.RenderInitial(c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func startNewSession(c echo.Context) error {
|
2024-12-16 15:29:54 -05:00
|
|
|
// Initialize the session
|
|
|
|
|
err := middleware.NewSession(c)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return middleware.RenderError(c, err)
|
|
|
|
|
}
|
2024-12-18 15:53:45 -05:00
|
|
|
return middleware.RenderInitial(c)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func continueExistingSession(c echo.Context, id string) error {
|
|
|
|
|
// Do some auth checks here
|
2024-12-16 15:29:54 -05:00
|
|
|
return middleware.RenderInitial(c)
|
|
|
|
|
}
|