View Source PlausibleWeb.UserAuth (Plausible v0.0.1)

Functions for user session management.

Summary

Functions

Link to this function

get_user_session(conn_or_session)

View Source
@spec get_user_session(Plug.Conn.t() | map()) ::
  {:ok, Plausible.Auth.UserSession.t()}
  | {:error, :no_valid_token | :session_not_found}
Link to this function

log_in_user(conn, user, redirect_path \\ nil)

View Source
@spec log_in_user(Plug.Conn.t(), Plausible.Auth.User.t(), String.t() | nil) ::
  Plug.Conn.t()
@spec log_out_user(Plug.Conn.t()) :: Plug.Conn.t()
Link to this function

revoke_all_user_sessions(user, opts \\ [])

View Source
@spec revoke_all_user_sessions(Plausible.Auth.User.t(), Keyword.t()) :: :ok
Link to this function

revoke_user_session(user, session_id)

View Source
@spec revoke_user_session(Plausible.Auth.User.t(), pos_integer()) :: :ok
Link to this function

set_logged_in_cookie(conn)

View Source
@spec set_logged_in_cookie(Plug.Conn.t()) :: Plug.Conn.t()

Sets the logged_in cookie share with the static site for determining whether client is authenticated.

As it's a separate cookie, there's a chance it might fall out of sync with session cookie state due to manual deletion or premature expiration.

Link to this function

touch_user_session(user_session, now \\ NaiveDateTime.utc_now(:second))

View Source