Skip to content

Verification Feature

Jimmy Oty edited this page Mar 7, 2023 · 1 revision

Verification Feature

User model

The User model is used to create user accounts. It has the following fields:

  • email: An email field to enter the email address of the user. This field is required and must be unique.
  • phone_number: A phone number field to enter the contact phone number of the user. This field is optional but must be unique if provided.
  • verification_code: A character field to store the verification code generated for the user. This field is required, unique and has a default value generated by the generate_verification_code() function.
  • code_generated_at: A datetime field that stores the date and time when the verification code was generated. This field is automatically generated by setting the auto_now_add attribute to True.
  • is_verified: A boolean field that indicates whether the user has been verified or not. This field is initially set to False and will be updated in the views when the user is verified.
  • USERNAME_FIELD: A string field that specifies the name of the field to use as the username field.
  • REQUIRED_FIELDS: A list of required fields to be filled in during registration, including first_name, last_name, username, and phone_number. The User model also has the following methods:

str(self): A method that returns a string representation of the user by concatenating the user's first name and last name. init(self, *args, region=None, **kwargs): An initializer that takes in the region and sets it to the region that was passed in when the user is created. get_verification_code(self): A method that resets the verification code after every hour if it has elapsed since the code was generated. It returns the verification code.

Clone this wiki locally