cover/Elixir.WalletAuth.Events.LoginFailed.html

1 defmodule WalletAuth.Events.LoginFailed do
2 @moduledoc "Emitted when a login attempt fails (wrong credentials, rate limited, etc.)."
3 @behaviour WalletEvents.DomainEvent
4
5 @impl true
6 5 def event_name, do: "LoginFailed.v1"
7
8 @impl true
9 5 def event_version, do: 1
10
11 @type reason :: :invalid_credentials | :rate_limited | :account_locked
12
13
:-(
def build(identifier, reason, opts \\ []) do
14 5 %{
15 event_id: WalletSharedKernel.Correlation.new_request_id(),
16 event_name: event_name(),
17 event_version: event_version(),
18 aggregate_id: identifier,
19 correlation_id: Keyword.get(opts, :correlation_id, WalletSharedKernel.Correlation.new_correlation_id()),
20 occurred_at: DateTime.utc_now(),
21 payload: %{
22 identifier: identifier,
23 reason: reason,
24 ip_address: Keyword.get(opts, :ip_address)
25 }
26 }
27 end
28 end
Line Hits Source