AuthShield v0.0.4 AuthShield.Authentication.LoginAttempts View Source

Every time an user try to log in its attempt is saved in order to check and temporary block after successive failed attempts.

It's done to mitigate attacks and suspicios login attempts.

Link to this section Summary

Types

Transactional responses of failed

Transactional responses of success

Link to this section Types

Link to this type

failed_response()

View Source
failed_response() :: {:error, Ecto.Changeset.t()}

Transactional responses of failed

Transactional responses of success

Link to this section Functions

Gets a AuthShield.Authentication.Schemas.LoginAttempt register by its filters.

Exemples:

  AuthShield.Authentication.LoginAttempts.get_by(user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e")

Gets a AuthShield.Authentication.Schemas.LoginAttempt register by its filters.

Similar to get_by/1 but returns the struct or raises if the changeset is invalid.

Creates a new AuthShield.Authentication.Schemas.LoginAttempt register.

Exemples:

  AuthShield.Authentication.LoginAttempts.insert(%{
    user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e",
    status: "success",
    remote_ip: "173.121.3.0",
    user_agent: "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0",
  })

Creates a new AuthShield.Authentication.Schemas.LoginAttempt register.

Similar to insert/1 but returns the struct or raises if the changeset is invalid.

Returns a list of AuthShield.Authentication.Schemas.LoginAttempt by its filters

Exemples:

  # Getting the all list
  AuthShield.Authentication.LoginAttempts.list()

  # Filtering the list by field
  AuthShield.Authentication.LoginAttempts.list(user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e")

Returns a list of AuthShield.Authentication.Schemas.LoginAttempt by its user_id, status and start date.

Exemples:

  AuthShield.Authentication.LoginAttempts.list_failure(user, ~N[2000-01-01 23:00:07])