Skip to content

Instantly share code, notes, and snippets.

@njwest
Created July 20, 2024 19:23
Show Gist options
  • Save njwest/11fbeef568ba66b261e5f44937619bef to your computer and use it in GitHub Desktop.
Save njwest/11fbeef568ba66b261e5f44937619bef to your computer and use it in GitHub Desktop.
# ...code omitted
require Logger
# ...code omitted
def allow_login_attempt?(email, limit \\ @login_request_limit) do
case ExRated.check_rate("login_attempt:#{email}", @time_window, limit) do
{:ok, _count} -> true
{:error, _limit} ->
Logger.warning("Login attempt limit exceeded for email: #{email}")
false
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment