AuthShield v0.0.1 AuthShield.Credentials.TOTP View Source
Time-based One-Time Password (TOTP) is an extension of the HMAC-based One-time Password algorithm (HOTP) generating a one-time password by instead taking uniqueness from the current time.
It is usually used with mobile applications that receives the secret key and generates the code to be used in authentications.
Thi module implements an interface to deal with database transactions as inserts, updates, deletes, etc.
Link to this section Summary
Functions
Checks if the given TOTP code matches the generated one.
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Gets a AuthShield.Credentials.Schemas.TOTP
register by its filters.
Gets a AuthShield.Credentials.Schemas.TOTP
register by its filters.
Creates a new AuthShield.Credentials.Schemas.TOTP
register.
Creates a new AuthShield.Credentials.Schemas.TOTP
register.
Returns a list of AuthShield.Credentials.Schemas.TOTP
by its filters
Link to this section Types
Transactional responses of failed
success_response()
View Sourcesuccess_response() :: {:ok, AuthShield.Credentials.Schemas.TOTP.t()}
Transactional responses of success
Link to this section Functions
check_totp?(totp, code, datetime_now \\ Timex.now())
View Sourcecheck_totp?( totp :: AuthShield.Credentials.Schemas.TOTP.t(), totp_code :: String.t(), now :: DateTime.t() ) :: boolean()
Checks if the given TOTP code matches the generated one.
Exemples:
# Using default timestamp
AuthShield.Credentials.TOTP.check_pin?(totp, "332456")
# Defining timestamp
AuthShield.Credentials.TOTP.check_pin?(totp, "332456", Timex.now("America/Chicago"))
delete(totp)
View Sourcedelete(totp :: AuthShield.Credentials.Schemas.TOTP.t()) :: success_response() | failed_response()
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Exemples:
AuthShield.Credentials.TOTP.delete(totp)
delete!(totp)
View Sourcedelete!(totp :: AuthShield.Credentials.Schemas.TOTP.t()) :: AuthShield.Credentials.Schemas.TOTP.t() | no_return()
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Similar to delete/1
but returns the struct or raises if the changeset is invalid.
get_by(filters)
View Sourceget_by(filters :: keyword()) :: AuthShield.Credentials.Schemas.TOTP.t() | nil
Gets a AuthShield.Credentials.Schemas.TOTP
register by its filters.
Exemples:
AuthShield.Credentials.TOTP.get_by(user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e")
get_by!(filters)
View Sourceget_by!(filters :: keyword()) :: AuthShield.Credentials.Schemas.TOTP.t() | no_return()
Gets a AuthShield.Credentials.Schemas.TOTP
register by its filters.
Similar to get_by/1
but returns the struct or raises if the changeset is invalid.
insert(params)
View Sourceinsert(params :: map()) :: success_response() | failed_response()
Creates a new AuthShield.Credentials.Schemas.TOTP
register.
Exemples:
# Simple insert
AuthShield.Credentials.TOTP.insert(%{
user_id: ecb4c67d-6380-4984-ae04-1563e885d59e",
email: "lucas@gmail.com"
})
# All parameters
AuthShield.Credentials.TOTP.insert(%{
user_id: ecb4c67d-6380-4984-ae04-1563e885d59e",
email: "lucas@gmail.com",
issuer: "MyWebpage",
digits: 4,
period: 60
})
insert!(params)
View Sourceinsert!(params :: map()) :: AuthShield.Credentials.Schemas.TOTP.t() | no_return()
Creates a new AuthShield.Credentials.Schemas.TOTP
register.
Similar to insert/1
but returns the struct or raises if the changeset is invalid.
list(filters \\ [])
View Sourcelist(filters :: keyword()) :: [AuthShield.Credentials.Schemas.TOTP.t()]
Returns a list of AuthShield.Credentials.Schemas.TOTP
by its filters
Exemples:
# Getting the all list
AuthShield.Credentials.TOTP.list()
# Filtering the list by field
AuthShield.Credentials.TOTP.list(user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e")