change behavior of reset password
- send email even if password is unusable - tell user if there's no user with that emailpull/43/head
parent
d968a800ae
commit
4aa968a523
|
@ -22,7 +22,7 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
||||||
<a href="{% url 'auth_password_reset' %}?next={% url 'receive_gift' gift.acq.nonce %}">Forgot</a> your password? <a href="{% url 'registration_register' %}?next={% url 'receive_gift' gift.acq.nonce %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
<a href="{% url 'libraryauth_password_reset' %}?next={% url 'receive_gift' gift.acq.nonce %}">Forgot</a> your password? <a href="{% url 'registration_register' %}?next={% url 'receive_gift' gift.acq.nonce %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
||||||
|
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<div>
|
<div>
|
||||||
<a href="{% url 'auth_password_reset' %}">Forgot</a> your password?
|
<a href="{% url 'libraryauth_password_reset' %}">Forgot</a> your password?
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -71,7 +71,7 @@ function put_un_in_cookie(){
|
||||||
</div>
|
</div>
|
||||||
<div class="halfcolumn1 login_box">
|
<div class="halfcolumn1 login_box">
|
||||||
<h3>Already Have an Unglue.it Account?</h3>
|
<h3>Already Have an Unglue.it Account?</h3>
|
||||||
<a href="{% url 'auth_password_reset' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? </li>
|
<a href="{% url 'libraryauth_password_reset' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? </li>
|
||||||
{% include "login_form.html" %}
|
{% include "login_form.html" %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Make sure the username box has your <b>username, not your email</b> -- some brow
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
||||||
<a href="{% url 'auth_password_reset' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? <a href="{% url 'registration_register' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
<a href="{% url 'libraryauth_password_reset' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Forgot</a> your password? <a href="{% url 'registration_register' %}?next={% if request.GET.next %}{{ request.GET.next|urlencode }}{% else %}{{ request.get_full_path|urlencode}}{% endif %}">Need an account</a>? <a href="/faq/basics/account">Other questions</a>?
|
||||||
|
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
|
from django.contrib.auth import get_user_model
|
||||||
|
from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from registration.forms import RegistrationForm
|
from registration.forms import RegistrationForm
|
||||||
|
@ -66,12 +67,20 @@ class AuthForm(AuthenticationForm):
|
||||||
else:
|
else:
|
||||||
super(AuthForm, self).__init__(*args, **kwargs)
|
super(AuthForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
class SocialAwarePasswordChangeForm(PasswordChangeForm):
|
class SocialAwarePasswordResetForm(PasswordResetForm):
|
||||||
def clean_old_password(self):
|
def get_users(self, email):
|
||||||
if self.user.has_usable_password():
|
"""
|
||||||
return super(SocialAwarePasswordChangeForm,self).clean_old_password()
|
Send the reset form even if the user password is not usable
|
||||||
else:
|
"""
|
||||||
return self.cleaned_data["old_password"]
|
active_users = get_user_model()._default_manager.filter(
|
||||||
|
email__iexact=email, is_active=True)
|
||||||
|
return active_users
|
||||||
|
|
||||||
|
def clean_email(self):
|
||||||
|
email = self.cleaned_data['email']
|
||||||
|
if not get_user_model().objects.filter(email__iexact=email, is_active=True).exists():
|
||||||
|
raise forms.ValidationError("There aren't ungluers with that email address!")
|
||||||
|
return email
|
||||||
|
|
||||||
|
|
||||||
class NewLibraryForm(forms.ModelForm):
|
class NewLibraryForm(forms.ModelForm):
|
||||||
|
|
|
@ -2,6 +2,7 @@ from django.conf.urls import patterns, url, include
|
||||||
from django.core.urlresolvers import reverse_lazy
|
from django.core.urlresolvers import reverse_lazy
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib.auth.views import password_reset
|
||||||
from . import views, models, forms
|
from . import views, models, forms
|
||||||
from .views import superlogin
|
from .views import superlogin
|
||||||
|
|
||||||
|
@ -58,6 +59,12 @@ urlpatterns = [
|
||||||
views.social_aware_password_change,
|
views.social_aware_password_change,
|
||||||
{'post_change_redirect': reverse_lazy('auth_password_change_done')},
|
{'post_change_redirect': reverse_lazy('auth_password_change_done')},
|
||||||
name='libraryauth_password_change'),
|
name='libraryauth_password_change'),
|
||||||
|
url(r'^password/reset/$',
|
||||||
|
password_reset,
|
||||||
|
{'post_reset_redirect': reverse_lazy('auth_password_reset_done'),
|
||||||
|
'password_reset_form': forms.SocialAwarePasswordResetForm},
|
||||||
|
name='libraryauth_password_reset'),
|
||||||
|
|
||||||
url(r'^socialauth/', include('social.apps.django_app.urls', namespace='social')),
|
url(r'^socialauth/', include('social.apps.django_app.urls', namespace='social')),
|
||||||
url('accounts/', include('email_change.urls')),
|
url('accounts/', include('email_change.urls')),
|
||||||
url(r'^accounts/', include('registration.backends.model_activation.urls')),
|
url(r'^accounts/', include('registration.backends.model_activation.urls')),
|
||||||
|
|
Loading…
Reference in New Issue