Reputation: 145
I have developed an app using Django. It uses Djoser for user authentication.
Problem: I have allowed user to register with already existing email addresses i.e. there might be multiple users using same email ID. So I can't reset password with the email field. Either I must use username only or the combination of username and email.
How can I do this?
Note:- Using base endpoint /users/reset_password/
but it requires email only to reset the password.
Upvotes: 0
Views: 1208
Reputation: 1551
One solution would be to add another field to djoser SendEmailResetSerializer. and perform additional validation in SendEmailResetSerializer.get_user method or validate method.
example:
DJOSER = {
'SERIALIZERS': {
'password_reset': 'path.to.CustomSendEmailResetSerializer',
},
}
class CustomSendEmailResetSerializer(SendEmailResetSerializer):
username = serializers.CharField(required=True)
class CustomSendEmailResetSerializer(SendEmailResetSerializer):
username = serializers.CharField(required=True)
def get_user(self, is_active=True):
# Retrieve user here.
return user
Upvotes: 1