Commit cceadff8 authored by Michal Čihař's avatar Michal Čihař

Remove password handling from email social auth

It really does not fit into it, it's better to ask user for setting
password later.
parent edbe4039
......@@ -219,19 +219,6 @@ class RegistrationForm(forms.Form):
label=_("E-mail"),
help_text=_('Activation email will be sent here.'),
)
password1 = forms.CharField(
widget=forms.PasswordInput(render_value=False),
label=_("Password"),
help_text=_('At least six characters long.'),
)
password2 = forms.CharField(
widget=forms.PasswordInput(render_value=False),
label=_("Password (again)"),
help_text=_(
'Repeat the password so we can verify '
'you typed it in correctly.'
),
)
first_name = forms.CharField(label=_('First name'))
last_name = forms.CharField(label=_('Last name'))
content = forms.CharField(required=False)
......@@ -273,16 +260,6 @@ class RegistrationForm(forms.Form):
)
return self.cleaned_data['email']
def clean_password1(self):
'''
Password validation, requires length of six chars.
'''
if len(self.cleaned_data['password1']) < 6:
raise forms.ValidationError(
_(u'Password needs to have at least six characters.')
)
return self.cleaned_data['password1']
def clean_content(self):
'''
Check if content is empty.
......@@ -290,44 +267,3 @@ class RegistrationForm(forms.Form):
if self.cleaned_data['content'] != '':
raise forms.ValidationError('Invalid value')
return ''
def clean(self):
"""
Verifiy that the values entered into the two password fields
match. Note that an error here will end up in
``non_field_errors()`` because it doesn't apply to a single
field.
"""
try:
password1 = self.cleaned_data['password1']
password2 = self.cleaned_data['password2']
if password1 != password2:
raise forms.ValidationError(
_('You must type the same password each time.')
)
except KeyError:
pass
return self.cleaned_data
def save(self):
'''
Creates user.
'''
user = User.objects.create(
email=self.cleaned_data['email'],
username=self.cleaned_data['username'],
first_name=self.cleaned_data['first_name'],
last_name=self.cleaned_data['last_name'],
is_active=False,
)
user.set_password(
self.cleaned_data['password1']
)
user.save()
# Ensure user has profile
Profile.objects.get_or_create(user=user)
return user
......@@ -44,27 +44,6 @@ def require_email(strategy, details, user=None, is_new=False,
return redirect('require_email')
def user_password(strategy, user, is_new=False, *args, **kwargs):
'''
Password validation/storing for email based auth.
'''
if strategy.backend_name != 'email':
return
request = strategy.request_data()
if ('password' not in request
or not user.check_password(request['password'])):
user.is_active = True
user.save()
raise AuthException(
strategy.backend,
_('Activation completed, you can now login.')
)
def send_validation(strategy, code):
'''
Sends verification email.
......
......@@ -80,7 +80,7 @@ class RegistrationTest(TestCase):
response = self.client.get(line[18:])
self.assertRedirects(
response,
reverse('registration_activation_complete')
reverse('home')
)
user = User.objects.get(username='username')
......
......@@ -72,6 +72,7 @@ urlpatterns = patterns(
),
name='email-sent'
),
url(r'^password/', 'accounts.views.password', name='password'),
url(r'^logout/', 'accounts.views.weblate_logout', name='logout'),
url(r'^profile/', 'accounts.views.user_profile', name='profile'),
url(r'^login/$', 'accounts.views.weblate_login', name='login'),
......
......@@ -263,7 +263,6 @@ def register(request):
if request.method == 'POST':
form = RegistrationForm(request.POST)
if form.is_valid() and appsettings.REGISTRATION_OPEN:
request.user = form.save()
return complete(request, 'email')
else:
form = RegistrationForm()
......@@ -281,3 +280,10 @@ def register(request):
}
)
)
def password(request):
if request.user.has_usable_password():
print 'US'
else:
print 'UNUS'
......@@ -192,7 +192,6 @@ SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.associate_by_email',
'accounts.pipeline.verify_open',
'social.pipeline.user.create_user',
'accounts.pipeline.user_password',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment