-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement plug bumping user session last used and timeout timestamps
- Loading branch information
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule PlausibleWeb.Plugs.UserSessionTouch do | ||
@moduledoc """ | ||
Plug for bumping timeout on user session on every dashboard request. | ||
""" | ||
|
||
import Plug.Conn | ||
|
||
alias PlausibleWeb.UserAuth | ||
|
||
def init(opts \\ []) do | ||
opts | ||
end | ||
|
||
def call(conn, _opts) do | ||
if user_session = conn.assigns[:current_user_session] do | ||
assign( | ||
conn, | ||
:current_user_session, | ||
UserAuth.touch_user_session(user_session) | ||
) | ||
else | ||
conn | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters