Hi
I'm deploying a multi site based shop and I need different users per site: End users needs to register on every site as independent stores.
I'd created a custom auth backend based in the original one that is handling the Auth part pretty well, but I have a problem in the registration. As the satchmo_store/accounts application check the email addres as unique, I need to override/modify the clean_email method inside the RegistrationForm. The only thing I need is a dummy site ID check but I don0t know how to do it without modify the Satchmo/Accounts code or fork the whole application. Can I do any kind of MonkeyPatching?
here is the Custom Auth backend:
class EmailSiteBackend(ModelBackend):
"""Authenticate using email only"""
def authenticate(self, username=None, password=None):
#If username is an email address, then try to pull it up
if email_re.search(username):
user = User.objects.filter(email__iexact=username)
if user.count() > 0:
user = user[0]
if user.get_profile().site == Site.objects.get_current():
if user.check_password(password):
return user
return None
and what I need to modify is the:
satchmo_store/accounts/forms.py:
class RegistrationForm(forms.Form):
......
def clean_email(self):
"""Prevent account hijacking by disallowing duplicate emails."""
email = self.cleaned_data.get('email', None)
if email and User.objects.filter(email__iexact=email).count() > 0:
raise forms.ValidationError(
ugettext("That email address is already in use."))
return email
to add the site check somehow