This is my models.py. I want to reset the password of the user by mobile number. Can't find answer yet. Can someone help to suggest any methods? Thanks in advance.
from django.db import models
from django.contrib.auth.models import User
class UserProfile(models.Model):
user = models.OneToOneField(User,null=True, on_delete=models.CASCADE)
mobile = models.CharField(max_length=15, blank=True, null=True)
def __str__(self):
return self.user.username
When a user requests a password reset, your server must generate a unique token (create a model for storing tokens) and then sends it to their phone number. The client sends the token back to the server with the new password, if the token is valid the password is changed, otherwise the token is invalidated. The token must have an expiration date (for example 3 minutes after the generation) and there can be only one valid token per user. You can use a third party service such as AWS Pinpoint (with boto3) or Twilio to send text messages.