Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added many fixes to auth module. #53

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pinax/apps/account/forms.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GroupForm(forms.Form):


def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.group = kwargs.pop("group", None) self.group = kwargs.pop("group", None)
kwargs.pop("request", None) #This is not stored. If needed, sub-class may store it.
super(GroupForm, self).__init__(*args, **kwargs) super(GroupForm, self).__init__(*args, **kwargs)




Expand Down Expand Up @@ -290,6 +291,7 @@ class UserForm(forms.Form):


def __init__(self, user=None, *args, **kwargs): def __init__(self, user=None, *args, **kwargs):
self.user = user self.user = user
kwargs.pop("request", None) #This is not stored. If needed, sub-class may store it.
super(UserForm, self).__init__(*args, **kwargs) super(UserForm, self).__init__(*args, **kwargs)




Expand Down Expand Up @@ -351,6 +353,11 @@ class ChangePasswordForm(UserForm):
widget = forms.PasswordInput(render_value=False) widget = forms.PasswordInput(render_value=False)
) )


def __init__(self, user=None, *args, **kwargs):
super(ChangePasswordForm, self).__init__(user, *args, **kwargs)
if not user.has_usable_password():
del self.fields['oldpassword'] #If password is not set or not usuable then oldpassword is not set.

def clean_oldpassword(self): def clean_oldpassword(self):
if not self.user.check_password(self.cleaned_data.get("oldpassword")): if not self.user.check_password(self.cleaned_data.get("oldpassword")):
raise forms.ValidationError(_("Please type your current password.")) raise forms.ValidationError(_("Please type your current password."))
Expand Down Expand Up @@ -395,6 +402,10 @@ class ResetPasswordForm(forms.Form):
required = True, required = True,
widget = forms.TextInput(attrs={"size":"30"}) widget = forms.TextInput(attrs={"size":"30"})
) )

def __init__(self, *args, **kwargs):
kwargs.pop("request", None) #This is not stored. If needed, sub-class may store it.
super(ResetPasswordForm, self).__init__(*args, **kwargs)


def clean_email(self): def clean_email(self):
if EmailAddress.objects.filter(email__iexact=self.cleaned_data["email"], verified=True).count() == 0: if EmailAddress.objects.filter(email__iexact=self.cleaned_data["email"], verified=True).count() == 0:
Expand Down Expand Up @@ -443,6 +454,7 @@ class ResetPasswordKeyForm(forms.Form):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.user = kwargs.pop("user", None) self.user = kwargs.pop("user", None)
self.temp_key = kwargs.pop("temp_key", None) self.temp_key = kwargs.pop("temp_key", None)
kwargs.pop("request", None) #This is not stored. If needed, sub-class may store it.
super(ResetPasswordKeyForm, self).__init__(*args, **kwargs) super(ResetPasswordKeyForm, self).__init__(*args, **kwargs)


def clean_password2(self): def clean_password2(self):
Expand Down
3 changes: 2 additions & 1 deletion pinax/apps/account/urls.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
url(r"^timezone/$", "pinax.apps.account.views.timezone_change", name="acct_timezone_change"), url(r"^timezone/$", "pinax.apps.account.views.timezone_change", name="acct_timezone_change"),
url(r"^language/$", "pinax.apps.account.views.language_change", name="acct_language_change"), url(r"^language/$", "pinax.apps.account.views.language_change", name="acct_language_change"),
url(r"^logout/$", "pinax.apps.account.views.logout", {"template_name": "account/logout.html"}, name="acct_logout"), url(r"^logout/$", "pinax.apps.account.views.logout", {"template_name": "account/logout.html"}, name="acct_logout"),
url(r"^confirm_email/(\w+)/$", "emailconfirmation.views.confirm_email", name="acct_confirm_email"), url(r"^confirm_email/(\w+)/$", "pinax.apps.account.views.confirm_email", name="acct_confirm_email"),
url(r"^confirm_email/(\w+)/$", "pinax.apps.account.views.confirm_email", name="emailconfirmation_confirm_email"), #Needed for reverse lookup in emailconfirmation to work.
url(r"^password_reset/$", "pinax.apps.account.views.password_reset", name="acct_passwd_reset"), url(r"^password_reset/$", "pinax.apps.account.views.password_reset", name="acct_passwd_reset"),
url(r"^password_reset/done/$", "pinax.apps.account.views.password_reset_done", name="acct_passwd_reset_done"), url(r"^password_reset/done/$", "pinax.apps.account.views.password_reset_done", name="acct_passwd_reset_done"),
url(r"^password_reset_key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$", "pinax.apps.account.views.password_reset_from_key", name="acct_passwd_reset_key"), url(r"^password_reset_key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$", "pinax.apps.account.views.password_reset_from_key", name="acct_passwd_reset_key"),
Expand Down
Loading