forked from plausible/analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and consolidate user session logic (plausible#4452)
* Extract session management from AuthController * Don't explicitly pass `current_user_id` to `live_render`'s session * Add ability to retrieve session and user from token via `UserAuth` * Always fetch current user (or just id) via `UserAuth` API * Introduce `UserSession` as an embedded schema for now * Make `UserAuth.get_user/1` accept `UserSession` as an input * Introduce LV auth context populating user data from session on mount * Refactor `AuthPlug` and make it populate `current_user_session` as well * Rely on authenticated user data provided by auth plug or LV context * Make `Sites.get_for_user(!)` accept `User` struct as well * Set `logged_in` cookie explicitly when it's out of sync with session * Expand modules documentation a bit * Improve and extend tests slightly
- Loading branch information
Showing
41 changed files
with
632 additions
and
265 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defmodule Plausible.Auth.UserSession do | ||
@moduledoc """ | ||
Schema for storing user session data. | ||
""" | ||
|
||
use Ecto.Schema | ||
|
||
@type t() :: %__MODULE__{} | ||
|
||
embedded_schema do | ||
field :user_id, :integer | ||
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
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
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
Oops, something went wrong.