entrance v0.1.0 Entrance.Login behaviour

This module provides boilerplate for creating Plugs for authentication with Entrance.

Modules that use Entrance.Login should implement a get_current_user/1 function that accepts a connection and returns either the current user, or nil.

Those modules should also implement helper functions such as login, logout, and etc. when applicable.

Example

defmodule MyApp.Auth do
  use Entrance.Login

  defp get_current_user(conn) do
    MyApp.Repo.get(MyApp.User, 1)
  end
end

Under the hood Entrance.Login implements the callbacks for the Plug behaviour. Both init/1 and call/2 are overridable.

Link to this section Summary

Callbacks

Returns either the current user or nil based on the state of the passed in conn.

Link to this section Callbacks

Link to this callback

get_current_user(arg1)

get_current_user(Plug.Conn.t()) :: struct() | nil

Returns either the current user or nil based on the state of the passed in conn.