affo_user_service.verification package

Submodules

affo_user_service.verification.exception module

exception affo_user_service.verification.exception.InvalidPhone

Bases: affo_user_service.verification.exception.VerificationError

exception affo_user_service.verification.exception.VerificationError

Bases: Exception

affo_user_service.verification.generators module

class affo_user_service.verification.generators.Generator

Bases: object

class affo_user_service.verification.generators.NumberGenerator

Bases: affo_user_service.verification.generators.Generator

Creates a random number.

Usage example

generator = NumberGenerator() print(generator()) # 1239

affo_user_service.verification.generators.get_generator(service_name)

Get the generator that is set for the specific service.

affo_user_service.verification.services module

class affo_user_service.verification.services.VerificationService(backend, verification_type)

Bases: object

The VerificationService is the main access point in this module. This service makes sure that there is a token generated as well as it has been send with the appropriate backend.

Variables
  • backend – the backend to be used (e.g. email, phone backend)

  • verification_type – The type of verification that is done (e.g. email, phone)

  • generator – Generator which returns a token to be passed

create_temporary_token(recipient, expiry=600)

Creates a temporary token inside the cache, this holds the phone recipient as value, so that we can later check if everything is correct.

Parameters
  • recipient – recipient of recipient

  • expiry – Expiry of the token, defaults to 3 hours.

Return token

string of sha token

send_verification(recipient, resend=False)

Send a verification email/ text to the given recipient to verify.

Parameters

recipient – the phone recipient/ email of recipient.

validate_token(recipient, token)

Check if given token is valid, compares it with the ones present in the cache.

Parameters
  • token – Token to be checked

  • value – The key it should be in

Returns boolean

Valid or not.

affo_user_service.verification.services.get_service(service_name)

Gets the service VerificationService, checks if there is already one in the memory, if so return that one.

Parameters

service_name – e.g. phone, email

Module contents