Reputation: 13
I have a request to alter a standard Django login of email and password to allow any user login without a password, but only if they are on a certain domain ... e.g. [email protected] ... where the user is allowed in due to them being on the correct domain.
Any suggestions?
Upvotes: 1
Views: 778
Reputation: 12195
Assuming that 'being on the correct domain' means they have an email address for the relevant domain, you could write a custom authentication backend that
In addition:
And finally:
Or, finally, finally:
Upvotes: 5
Reputation: 473
Somehow like this:
if cleaned_data['email'].endswith('@example.com'):
user = None
try:
user = User.objects.get(email = cleaned_data['email'])
except:
pass
if user:
login(request, user)
Your concept allows everyone knowing or guessing one of the affected email-addresses to login without using a password!
Best regards!
Upvotes: 0
Reputation: 74675
If your user has an openid with the email [email protected]
then you can use an OpenId solution (say Django-openid; there are others too) to verify his identity and allow him access.
If that is unlikely, then you'll need to find a custom way of ensuring that the user is who he claims to be.
Upvotes: 1