View Source SmsUp.Pin.Store (sms_up v1.3.2)

This module stores random pin associated with an id to be checked later. Default validity is 15 minutes and is configurable (value to be given in minutes): config :sms_up, pin_validity: 20

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

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.

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

@spec store(any()) :: {:error, String.t()} | {:ok, 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"}
@spec 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}