SmsUp.Pin.Store (sms_up v0.3.1) View Source

This module stores random pin associated with an id to be checked later. Default validity is 10 minutes and is configurable: config :sms_up, pin_validity: 15

Default token size is 6 and can be modified also: config :sms_up, :pin_size, 4

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Generate a pin code for the given id and store it in a mnesia database. Returns the generated pin code.

Validate a pin code along with the user id and tells if the provided pin is correct or not. Returns a tupple containing true or false regarding the result.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

store(any()) :: {:ok, String.t()} | {:error, String.t()}

Generate a pin code for the given id and store it in a mnesia database. Returns the generated pin code.

Examples

iex> SmsUp.Pin.Store.store("user@email.ch")
{:ok, "123456"}

Specs

validate(any(), String.t()) :: {:ok, true} | {:ok, false}

Validate a pin code along with the user id and tells if the provided pin is correct or not. Returns a tupple containing true or false regarding the result.

Examples

iex> SmsUp.Pin.Store.validate("user@email.ch", "Good Pin")
{:ok, true}

iex> SmsUp.Pin.Store.validate("user@email.ch", "Wrong Pin")
{:ok, false}