AshAuthentication.Strategy.RememberMe.Plug.Helpers (ash_authentication v4.13.3)

View Source

Plug for signing in with remember me token in cookies.

Summary

Functions

Get all the remember me cookie names for the given otp_app.

Delete all the remember me tokens from the response cookies.

Delete the remember me token from the connection response cookies.

Take a connection and possibly an authentication result tuple, call the endpoint to put the remember me cookie

Put the remember me token in connection response cookies.

Sign in the given Ash Resource with the AshAuthentication RememberMe strategy. To sign in with any Ash Resource see sign_in_resource_with_remember_me.

Functions

delete_all_remember_me_cookies(conn, otp_app)

@spec delete_all_remember_me_cookies(Plug.Conn.t(), atom()) :: Plug.Conn.t()

Delete all the remember me tokens from the response cookies.

delete_remember_me_cookie(conn, cookie_name)

@spec delete_remember_me_cookie(Plug.Conn.t(), String.t()) :: Plug.Conn.t()

Delete the remember me token from the connection response cookies.

maybe_put_remember_me_cookies(conn_with_auth_result, return_to)

@spec maybe_put_remember_me_cookies({Plug.Conn.t(), any()} | Plug.Conn.t(), any()) ::
  {Plug.Conn.t(), any()} | Plug.Conn.t()

Take a connection and possibly an authentication result tuple, call the endpoint to put the remember me cookie

put_remember_me_cookie(conn, cookie_name, map)

@spec put_remember_me_cookie(Plug.Conn.t(), String.t(), map()) :: Plug.Conn.t()

Put the remember me token in connection response cookies.

sign_in_resource_with_remember_me(conn, resource, opts)

@spec sign_in_resource_with_remember_me(Plug.Conn.t(), Ash.Resource.t(), Keyword.t()) ::
  Plug.Conn.t() | {Plug.Conn.t(), Ash.Resource.record()}

Sign in the given Ash Resource with the AshAuthentication RememberMe strategy. To sign in with any Ash Resource see sign_in_resource_with_remember_me.

For the given resource, find the remember me strategies.

If no remember me strategies are found, do nothing.

If a remember me strategy is found, but no token is found, do nothing.

If a remember me strategy is found, and a token is found in the cookies, and the token is valid, login the user.

If a remember me strategy is found, and a token is found in the cookies, and the token is invalid, delete the cookie.