affo_user_service.verification package


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


Get the generator that is set for the specific service. module

class, 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.

  • 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.

  • 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.


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.

  • token – Token to be checked

  • value – The key it should be in

Returns boolean

Valid or not.

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


service_name – e.g. phone, email

Module contents