AuthShield v0.0.2 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 Functions
check_totp?(totp, code, now \\ NaiveDateTime.utc_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", NaiveDateTime.utc_now())
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Exemples:
AuthShield.Credentials.TOTP.delete(totp)
Deletes a AuthShield.Credentials.Schemas.TOTP
register.
Similar to delete/1
but returns the struct or raises if the changeset is invalid.
Gets a AuthShield.Credentials.Schemas.TOTP
register by its filters.
Exemples:
AuthShield.Credentials.TOTP.get_by(user_id: "ecb4c67d-6380-4984-ae04-1563e885d59e")
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.
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
})
Creates a new AuthShield.Credentials.Schemas.TOTP
register.
Similar to insert/1
but returns the struct or raises if the changeset is invalid.
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")