Current section

Files

Jump to
perspective lib perspective core authentication authentication_vault.ex
Raw

lib/perspective/core/authentication/authentication_vault.ex

defmodule Perspective.Core.AuthenticationVault do
use Perspective.Reactor
initial_state do
%{}
end
update(%Perspective.Core.UserAdded{data: data}, state) do
Map.put(state, data.username, data)
end
def credentials_for(username) do
case data() |> Map.get(username, nil) do
nil -> {:error, %Perspective.Authentication.UsernameNotFound{username: username}}
password_hash -> {:ok, password_hash}
end
end
end