Fix login redirects
This commit is contained in:
parent
897d973b8d
commit
642e7785a1
@ -20,6 +20,11 @@ func HandleAuth(sc context.Context, action string) echo.HandlerFunc {
|
|||||||
return LnAuth(sc, c, action)
|
return LnAuth(sc, c, action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// on session guard redirects to /login,
|
||||||
|
// we need to make sure that HTMX selects and targets correct element
|
||||||
|
c.Response().Header().Add("HX-Retarget", "#content")
|
||||||
|
c.Response().Header().Add("HX-Reselect", "#content")
|
||||||
|
|
||||||
return pages.Auth(mapAction(action)).Render(context.RenderContext(sc, c), c.Response().Writer)
|
return pages.Auth(mapAction(action)).Render(context.RenderContext(sc, c), c.Response().Writer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func SessionGuard(sc context.Context) echo.MiddlewareFunc {
|
|||||||
session := c.Get("session")
|
session := c.Get("session")
|
||||||
if session == nil {
|
if session == nil {
|
||||||
// this seems to work for non-interactive and htmx requests
|
// this seems to work for non-interactive and htmx requests
|
||||||
return c.Redirect(http.StatusTemporaryRedirect, "/login")
|
return c.Redirect(http.StatusSeeOther, "/login")
|
||||||
}
|
}
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user