Commits

offline  committed 8131df8

confirmation bugfix and new get_url method used

  • Participants
  • Parent commits 5e25a4c

Comments (0)

Files changed (1)

File openauth/views.py

 import openauth
 from openauth.forms import ResetPasswordForm, NewPasswordForm, LoginForm, \
      OpenIDLoginForm, OpenIDRegistrationForm
-from openauth.utils import email_template, build_redirect_url, str_to_class, \
-    generate_hash, activation_required
+from openauth.utils import email_template, build_redirect_url, str_to_class, activation_required
 from openauth.models import OpenID
 
 
             if openauth.settings.ACTIVATION_REQUIRED:
                 confirmation = Confirmation.objects.create(user, 
                                                            openauth.settings.ACTIVATION_CONFIRMATION_TYPE)
-                url = request.build_absolute_uri(reverse('confirmation'))
-                url += '?key=%s&type=%s' % (confirmation.key, confirmation.confirmation_type)
-                params = {'domain': request.get_host(), 'email': user.email, 'url': url}
+                params = {'domain': request.get_host(), 'email': user.email, 'url': confirmation.get_url(request)}
                 if email_template(user.email, 'openauth/mail/registration.txt', **params):
                     return notify_user.success(request, "/", openauth.lang.PLEASE_ACTIVATE)
                 else:
             user = User.objects.get(email=form.cleaned_data['email'].lower())
             confirmation = Confirmation.objects.create(user, 
                                                        openauth.settings.PASSWORD_RESET_CONFIRMATION_TYPE)
-            url = request.build_absolute_uri(reverse('openauth-confirm'))
-            url += '?key=%s&type=%s' % (confirmation.key, openauth.settings.PASSWORD_RESET_CONFIRMATION_TYPE)
-            args = {'domain': request.get_host(), 'url': url}
+            args = {'domain': request.get_host(), 'url': confirmation.get_url(request)}
             if email_template(user.email, 'openauth/mail/reset_password.txt', **args):
                 return notify_user.notice(request, "/",  _('Check your email please'))
             else:
     if form.is_valid():
         user = form.save()
         confirmation = Confirmation.objects.create(user, openauth.settings.ACTIVATION_CONFIRMATION_TYPE)
-        confirmation.save()
-        url = request.build_absolute_uri(reverse('openauth-confirm'))
-        url += '?key=%s' % confirmation.key
-        params = {'domain': 'localhost:8000', 'email': user.email, 'url': url}
+        params = {'domain': request.get_host(), 'email': user.email, 'url': confirmation.get_url(request)}
         email_template(user.email, 'openauth/mail/registration.txt', **params)
         del request.session['authenticated_openid_url']
         return notify_user.success(request, "openauth-show-user", openauth.lang.PLEASE_ACTIVATE)