feat: add /bookshelf route and update redirects
- Add /bookshelf route as default page for logged-in users - Update login and register handlers to redirect to /bookshelf - Update homepage to auto-redirect to /bookshelf when logged in - Preserve /dashboard route for backward compatibility - Update test redirects to use /bookshelf Changes: - main.go: Add /bookshelf protected route - auth.go: Change login/register redirects from /api/dashboard to /bookshelf (2 locations) - edge_cases_test.go: Update test redirect to /bookshelf - Maintains backward compatibility with existing /dashboard route This makes the beautiful bookshelf the default landing page for all authenticated users while keeping the old dashboard accessible.
This commit is contained in:
+23
-1
@@ -168,7 +168,29 @@ func main() {
|
||||
}
|
||||
}()
|
||||
|
||||
// Dashboard route (protected)
|
||||
// Bookshelf route (protected) - new default for logged-in users
|
||||
protected.GET("/bookshelf", func(c echo.Context) error {
|
||||
userID := c.Get("user_id").(string)
|
||||
userEmail := c.Get("user_email").(string)
|
||||
userUsername := c.Get("user_username").(string)
|
||||
userRole := c.Get("user_role").(string)
|
||||
|
||||
user := templates.User{
|
||||
ID: userID,
|
||||
Email: userEmail,
|
||||
Username: userUsername,
|
||||
Role: userRole,
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
err := templates.BookShelf(user).Render(c.Request().Context(), &buf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return c.HTML(http.StatusOK, buf.String())
|
||||
})
|
||||
|
||||
// Dashboard route (protected) - keep for backward compatibility
|
||||
protected.GET("/dashboard", func(c echo.Context) error {
|
||||
userID := c.Get("user_id").(string)
|
||||
userEmail := c.Get("user_email").(string)
|
||||
|
||||
Reference in New Issue
Block a user