Add the auth pipeline for the Link API path.
This commit is contained in:
@@ -4,6 +4,10 @@ defmodule LinkShortener.AccountsFixtures do
|
||||
entities via the `LinkShortener.Accounts` context.
|
||||
"""
|
||||
|
||||
alias LinkShortener.Accounts
|
||||
alias LinkShortener.Accounts.User
|
||||
alias LinkShortenerWeb.Auth.Guardian
|
||||
|
||||
@doc """
|
||||
Generate a unique user email.
|
||||
"""
|
||||
@@ -26,6 +30,18 @@ defmodule LinkShortener.AccountsFixtures do
|
||||
user
|
||||
end
|
||||
|
||||
def user_token_fixture(attrs \\ %{}) do
|
||||
user_params = %{
|
||||
email: "user@mail.com",
|
||||
password: "hello world 12345"
|
||||
}
|
||||
|
||||
{:ok, %User{} = user} = Accounts.register_user(user_params)
|
||||
{:ok, token, _claims} = Guardian.encode_and_sign(user)
|
||||
|
||||
token
|
||||
end
|
||||
|
||||
def extract_user_token(fun) do
|
||||
{:ok, captured_email} = fun.(&"[TOKEN]#{&1}[TOKEN]")
|
||||
[_, token | _] = String.split(captured_email.text_body, "[TOKEN]")
|
||||
|
||||
Reference in New Issue
Block a user