PasswordlessAuth v0.1.1 PasswordlessAuth View Source
PasswordlessAuth is a library gives you the ability to verify a user’s phone number by sending them a verification code, and verifying that the code they provide matches the code that was sent to their phone number.
Verification codes are stored in an Agent along with the phone number they were sent to. They are stored with an expiration date/time.
A garbage collector removes expires verification codes from the store. See PasswordlessAuth.GarbageCollector
Link to this section Summary
Functions
Send an SMS with a verification code to the given phone_number
Removes a code from state based on the given phone_number
Verifies that a the given phone_number
has the
given verification_code
stores in state and that
the verification code hasn’t expired
Link to this section Functions
Send an SMS with a verification code to the given phone_number
The verification code is valid for the number of seconds given to the
verification_code_ttl
config option (defaults to 300)
Options for the Twilio request can be passed to opts[:twilio_request_options
.
You’ll need to pass at least a from
or messaging_service_sid
option
to options[:twilio_request_options]
for messages to be sent
(see the Twilio API documentation)
For example:
Arguments:
phone_number
: The phone number that will receive the text messageopts
: Options (see below)
Options:
message
: A custom text message template. The verification code can be injected with this formatting: “Yarrr, {{code}} be the secret”. Defaults to “Your verification code is: {{code}}”code_length
: Length of the verification code (defaults to 6)twilio_request_options
: A map of options that are passed to the Twilio request (see the Twilio API documentation)
Returns {:ok, twilio_response}
or {:error, error}
.
Removes a code from state based on the given phone_number
Returns {:ok, %VerificationCode{...}}
or {:error, :reason}
.
Verifies that a the given phone_number
has the
given verification_code
stores in state and that
the verification code hasn’t expired.
Returns true
or false
.
Examples
iex> PasswordlessAuth.verify_code("+447123456789", "123456")
false