From 2ec7c6ea09dc356e6c5cb12b34749f83fba6400b Mon Sep 17 00:00:00 2001 From: Pasi Eronen Date: Thu, 8 Oct 2009 17:41:15 +0000 Subject: [PATCH] Removed account creation/password changing functionality - Legacy-Id: 1722 --- ietf/ietfauth/forms.py | 40 -------- ietf/ietfauth/testurl.list | 1 - ietf/ietfauth/urls.py | 5 - ietf/ietfauth/views.py | 99 ------------------- ietf/templates/registration/action_done.html | 23 ----- .../templates/registration/bad_challenge.html | 22 ----- .../registration/challenge_sent.html | 13 --- .../registration/new_person_form.html | 18 ---- .../registration/password_change_done.html | 11 --- .../registration/password_change_form.html | 23 ----- .../templates/registration/password_email.txt | 9 -- .../templates/registration/password_form.html | 22 ----- .../registration/password_request.html | 17 ---- 13 files changed, 303 deletions(-) delete mode 100644 ietf/ietfauth/forms.py delete mode 100644 ietf/templates/registration/action_done.html delete mode 100644 ietf/templates/registration/bad_challenge.html delete mode 100644 ietf/templates/registration/challenge_sent.html delete mode 100644 ietf/templates/registration/new_person_form.html delete mode 100644 ietf/templates/registration/password_change_done.html delete mode 100644 ietf/templates/registration/password_change_form.html delete mode 100644 ietf/templates/registration/password_email.txt delete mode 100644 ietf/templates/registration/password_form.html delete mode 100644 ietf/templates/registration/password_request.html diff --git a/ietf/ietfauth/forms.py b/ietf/ietfauth/forms.py deleted file mode 100644 index cb148b1a0..000000000 --- a/ietf/ietfauth/forms.py +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright The IETF Trust 2007, All Rights Reserved -from django import newforms as forms -from django.conf import settings -import hmac, sha -import time - -class EmailForm(forms.Form): - email = forms.EmailField() - -def email_hash(email, timestamp): - return hmac.new(settings.SECRET_KEY, "%d%s" % (timestamp, email), sha).hexdigest() - -class ChallengeForm(forms.Form): - email = forms.EmailField() - timestamp = forms.IntegerField() - hash = forms.CharField() - def clean_timestamp(self): - now = int(time.time()) - timestamp = self.clean_data['timestamp'] - if timestamp > now: - raise forms.ValidationError, 'Timestamp in the future' - if timestamp < (now - 86400*settings.PASSWORD_DAYS): - raise forms.ValidationError, 'Timestamp is too old' - return timestamp - def clean_hash(self): - if self.clean_data['hash'] != email_hash(self.clean_data['email'], self.clean_data['timestamp']): - raise forms.ValidationError, 'Hash is incorrect' - return self.clean_data['hash'] - -class PWForm(forms.Form): - password = forms.CharField(label='Enter your desired password', widget=forms.PasswordInput()) - repeat = forms.CharField(label='Re-enter the same password', widget=forms.PasswordInput()) - def clean_repeat(self): - if self.clean_data['password'] != self.clean_data['repeat']: - raise forms.ValidationError, 'Passwords do not match' - -# Field lengths from PersonOrOrgInfo -class FirstLastForm(forms.Form): - first = forms.CharField(label='First Name', max_length=20, widget = forms.TextInput(attrs = {'size': 20})) - last = forms.CharField(label='Last Name', max_length=50, widget = forms.TextInput(attrs = {'size': 50})) diff --git a/ietf/ietfauth/testurl.list b/ietf/ietfauth/testurl.list index 22e646cd3..65d9f48a6 100644 --- a/ietf/ietfauth/testurl.list +++ b/ietf/ietfauth/testurl.list @@ -1,2 +1 @@ -302 /account/password_change/ 302 /account/profile/ diff --git a/ietf/ietfauth/urls.py b/ietf/ietfauth/urls.py index a2a04a019..3ad31f210 100644 --- a/ietf/ietfauth/urls.py +++ b/ietf/ietfauth/urls.py @@ -7,13 +7,8 @@ from ietf.my.views import my urlpatterns = patterns('django.contrib.auth.views', (r'^login/$', 'login'), (r'^logout/$', 'logout'), - (r'^password_change/$', 'password_change'), - (r'^password_change/done/$', 'password_change_done'), ) urlpatterns += patterns('', (r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'registration/account_info.html'}), - (r'^request/$', views.password_request), - (r'^return/$', views.password_return), - (r'^return/(?P\w+)/$', 'django.views.generic.simple.direct_to_template', {'template': 'registration/action_done.html'}), (r'^profile/$', my) ) diff --git a/ietf/ietfauth/views.py b/ietf/ietfauth/views.py index 26ba0cf44..a4b306690 100644 --- a/ietf/ietfauth/views.py +++ b/ietf/ietfauth/views.py @@ -1,101 +1,2 @@ # Copyright The IETF Trust 2007, All Rights Reserved -from django.conf import settings -from django.shortcuts import render_to_response -from django.template.context import RequestContext -from django.http import HttpResponseRedirect -from django.contrib.sites.models import Site -from django.contrib.auth.models import User -from ietf.idtracker.models import PersonOrOrgInfo -from ietf.ietfauth.models import UserMap -from ietf.ietfauth.forms import EmailForm, ChallengeForm, PWForm, FirstLastForm, email_hash -from ietf.ietfauth.auth import set_password -from ietf.utils.mail import send_mail -from ietf.utils.users import create_user -from ietf.utils.log import log -import time -def password_request(request): - if request.method == 'POST': - form = EmailForm(request.POST) - if form.is_valid(): - timestamp = int(time.time()) - email = form.clean_data['email'] - hash = email_hash(email, timestamp) - site = Site.objects.get_current() - context = {'timestamp': timestamp, 'email': email, 'hash': hash, 'days': settings.PASSWORD_DAYS, 'site': site} - send_mail(request, email, None, 'IETF Datatracker Password', - 'registration/password_email.txt', context, toUser=True) - return render_to_response('registration/challenge_sent.html', context, - context_instance=RequestContext(request)) - else: - form = EmailForm() - return render_to_response('registration/password_request.html', {'form': form}, - context_instance=RequestContext(request)) - -def password_return(request): - form = ChallengeForm(request.REQUEST) - if form.is_valid(): - email = form.clean_data['email'] - method = request.method - try: - # Is there a django user? - user = User.objects.get(email__iexact=email) - try: - usermap = UserMap.objects.get(user=user) - person = usermap.person - except UserMap.DoesNotExist: - person = None - except User.DoesNotExist: - # Is there an IETF person, and a usermap to a django user, - # e.g., the django user table has the wrong email address? - user = None - try: - person = PersonOrOrgInfo.objects.distinct().get(emailaddress__address__iexact=email) - try: - usermap = UserMap.objects.get(person=person) - user = usermap.user - except UserMap.DoesNotExist: - pass - except PersonOrOrgInfo.DoesNotExist: - person = None - if person is None: - # If there's no IETF person, try creating one. - if method == 'POST': - flform = FirstLastForm(request.POST) - if flform.is_valid(): - person = PersonOrOrgInfo( first_name=flform.clean_data['first'], last_name=flform.clean_data['last'], created_by='SelfSvc' ) - person.save() - person.emailaddress_set.create( type='INET', priority=1, address=email, comment='Created with SelfService' ) - # fall through to "if user or person" - # hack: - # pretend to the fall-through form that we used GET. - method = 'GET' - else: - flform = FirstLastForm() - return render_to_response('registration/new_person_form.html', {'form': form, 'flform': flform}, - context_instance=RequestContext(request)) - if user or person: - # form to get a password, either for reset or new user - if method == 'POST': - pwform = PWForm(request.POST) - if pwform.is_valid(): - pw = pwform.clean_data['password'] - if user: - set_password(user, pw) - user.save() - return HttpResponseRedirect('changed/') - else: - create_user(None, email, person, pw=pw) - return HttpResponseRedirect('created/') - else: - pwform = PWForm() - return render_to_response('registration/password_form.html', {'u': user, 'person': person, 'form': form, 'pwform': pwform}, - context_instance=RequestContext(request)) - else: - # We shouldn't get here. - return render_to_response('registration/generic_failure.html', {}, - context_instance=RequestContext(request)) - else: - log("bad challenge for %s: %s" % (form.data.get('email', ''), form.errors.as_text().replace('\n', ' ').replace(' *', ':'))) - return render_to_response('registration/bad_challenge.html', {'form': form, 'days': settings.PASSWORD_DAYS}, - context_instance=RequestContext(request)) diff --git a/ietf/templates/registration/action_done.html b/ietf/templates/registration/action_done.html deleted file mode 100644 index 746d4a796..000000000 --- a/ietf/templates/registration/action_done.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Success{% endblock %} - -{% block content %} -

Success

- -

Your -{% ifequal params.action "changed" %} -password -{% else %} -account -{% endifequal %} -has been {{ params.action }}. You can bask in the glow of your -{% ifequal params.action "changed" %} -changed password, -{% else %} -new account, -{% endifequal %} -or you can visit the -login page and exercise it. -

-{% endblock %} diff --git a/ietf/templates/registration/bad_challenge.html b/ietf/templates/registration/bad_challenge.html deleted file mode 100644 index c6b3acec8..000000000 --- a/ietf/templates/registration/bad_challenge.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Bad Challenge{% endblock %} - -{% block content %} -

Bad Challenge

- -

Sorry, the URL you used was incorrect. Make sure that you copied it -properly from the email you received.

- -{% comment %} -if we feel like it, report the detailed error - - -{{ form }} -
DEBUG
-{% endcomment %} - -

Note that these URLs expire after {{ days }} days, so you may need -to request -another one.

-{% endblock %} diff --git a/ietf/templates/registration/challenge_sent.html b/ietf/templates/registration/challenge_sent.html deleted file mode 100644 index a3ebc8574..000000000 --- a/ietf/templates/registration/challenge_sent.html +++ /dev/null @@ -1,13 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Challenge Sent{% endblock %} - -{% block content %} -

Challenge Sent

- -

-A URL has been sent to the email address that you provided. -Wait for that message to arrive, then come back to the URL -provided in the email to continue your requested operation. -

-{% endblock %} diff --git a/ietf/templates/registration/new_person_form.html b/ietf/templates/registration/new_person_form.html deleted file mode 100644 index 057644dab..000000000 --- a/ietf/templates/registration/new_person_form.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends "base.html" %} - -{% block title %}New User Creation{% endblock %} - -{% block content %} -Creating New IETF User -
-{# keep the challenge token with the transaction #} -{{ form.timestamp.as_hidden }} -{{ form.email.as_hidden }} -{{ form.hash.as_hidden }} - -{{ flform }} -
- -
- -{% endblock %} diff --git a/ietf/templates/registration/password_change_done.html b/ietf/templates/registration/password_change_done.html deleted file mode 100644 index 46db3994b..000000000 --- a/ietf/templates/registration/password_change_done.html +++ /dev/null @@ -1,11 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Password change successful{% endblock %} - -{% block content %} - -

Password change successful

- -

Your password was changed.

- -{% endblock %} diff --git a/ietf/templates/registration/password_change_form.html b/ietf/templates/registration/password_change_form.html deleted file mode 100644 index 42a0b19be..000000000 --- a/ietf/templates/registration/password_change_form.html +++ /dev/null @@ -1,23 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Password change{% endblock %} - -{% block content %} - -

Password change

- -

Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly.

- -
- -{% if form.old_password.errors %}{{ form.old_password.html_error_list }}{% endif %} -

{{ form.old_password }}

-{% if form.new_password1.errors %}{{ form.new_password1.html_error_list }}{% endif %} -

{{ form.new_password1 }}

-{% if form.new_password2.errors %}{{ form.new_password2.html_error_list }}{% endif %} -

{{ form.new_password2 }}

- -

-
- -{% endblock %} diff --git a/ietf/templates/registration/password_email.txt b/ietf/templates/registration/password_email.txt deleted file mode 100644 index 8b97392e6..000000000 --- a/ietf/templates/registration/password_email.txt +++ /dev/null @@ -1,9 +0,0 @@ -Hi, - -{% filter wordwrap:72 %}Someone gave this email address as theirs when requesting a password change or new account at {{ site.name }}. If that was you, please visit this URL to continue the process:{% endfilter %} - -http://{{ site.domain }}{% url ietf.ietfauth.views.password_return %}?timestamp={{ timestamp }}&email={{ email|urlencode }}&hash={{ hash }} - -This link is valid for {{ days }} days. - -If that someone wasn't you, then you can ignore this email. diff --git a/ietf/templates/registration/password_form.html b/ietf/templates/registration/password_form.html deleted file mode 100644 index e3a3135af..000000000 --- a/ietf/templates/registration/password_form.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Password Entry{% endblock %} - -{% block content %} -{% if u %} -Resetting password for {{ u.username }} ({{ u.get_full_name|escape }}). -{% else %} -Creating new account for {{ person }} -{% endif %} -
-{# keep the challenge token with the transaction #} -{{ form.timestamp.as_hidden }} -{{ form.email.as_hidden }} -{{ form.hash.as_hidden }} - -{{ pwform }} -
- -
- -{% endblock %} diff --git a/ietf/templates/registration/password_request.html b/ietf/templates/registration/password_request.html deleted file mode 100644 index 147f0c634..000000000 --- a/ietf/templates/registration/password_request.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "base.html" %} - -{% block title %}Password Request{% endblock %} - -{% block content %} -

Password Request

- -

This form allows you to confirm that you own an email address, -in order to change your password or register a new account.

- -
- -{{ form }} -
- -
-{% endblock %}