, Authsense

Sensible authentication helpers for Phoenix/Ecto

Status

Installation

Add authsense to your list of dependencies in mix.exs:

def deps do
  [{:authsense, "~> 1.0.0"}]
end

Overview

Please consult the Authsense documentation for full details.

Configure authsense:

config :authsense, Myapp.User,
   repo: Myapp.Repo

You can then call some helpers for authentication:

# For login actions
authenticate(changeset)  #=> {:ok, user} or {:error, changeset_with_errors}
authenticate({ "userid", "password" })  #=> %User{} | nil
# For login/logout actions
conn |> put_current_user(user)  # login
conn |> put_current_user(nil)   # logout
# For model changesets
changeset
|> generate_hashed_password()
# For controllers
import Authsense.Plug
plug :fetch_current_user
conn.assigns.current_user  #=> %User{} | nil

Please consult the Authsense documentation detailed info.

Thanks

authsense © 2016-2017, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).

ricostacruz.com  ·  GitHub @rstacruz  ·  Twitter @rstacruz