mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 17:44:43 +03:00
Redirect to login on expired legacy session (#4523)
After refactor, it turned out that when the _legacy_ session times out, the conn is halted but no body is sent. This results in 500 error (`Plug.Conn.NotSentError`). This PR fixes it by redirecting to login page.
This commit is contained in:
parent
530d290678
commit
d0619aaea0
@ -18,6 +18,7 @@ defmodule PlausibleWeb.SessionTimeoutPlug do
|
||||
user_id && timeout_at && now() > timeout_at ->
|
||||
conn
|
||||
|> PlausibleWeb.UserAuth.log_out_user()
|
||||
|> Phoenix.Controller.redirect(to: "/login")
|
||||
|> halt()
|
||||
|
||||
user_id ->
|
||||
|
@ -41,5 +41,7 @@ defmodule PlausibleWeb.SessionTimeoutPlugTest do
|
||||
|> SessionTimeoutPlug.call(@opts)
|
||||
|
||||
assert conn.private[:plug_session_info] == :renew
|
||||
assert conn.halted
|
||||
assert Phoenix.ConnTest.redirected_to(conn, 302) == "/login"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user