- Handles login, registration, and forgotten passwords. In other words, this
- multiview provides exclusively view and methods related to usernames and
- passwords.
+ Handles exclusively methods and views related to logging users in and out.
"""
login_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_login_related')
login_form = WaldoAuthenticationForm
"""
login_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_login_related')
login_form = WaldoAuthenticationForm
password_reset_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_related', blank=True, null=True)
password_reset_confirmation_email = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_confirmation_email_related', blank=True, null=True)
password_set_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_set_related', blank=True, null=True)
password_change_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_change_related', blank=True, null=True)
password_reset_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_related', blank=True, null=True)
password_reset_confirmation_email = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_reset_confirmation_email_related', blank=True, null=True)
password_set_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_set_related', blank=True, null=True)
password_change_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_password_change_related', blank=True, null=True)
- def make_confirmation_link(self, confirmation_view, token_generator, user, node, token_args=None, reverse_kwargs=None):
+ def make_confirmation_link(self, confirmation_view, token_generator, user, node, token_args=None, reverse_kwargs=None, secure=False):
token = token_generator.make_token(user, *(token_args or []))
kwargs = {
'uidb36': int_to_base36(user.id),
'token': token
}
kwargs.update(reverse_kwargs or {})
token = token_generator.make_token(user, *(token_args or []))
kwargs = {
'uidb36': int_to_base36(user.id),
'token': token
}
kwargs.update(reverse_kwargs or {})
- return node.construct_url(subpath=self.reverse(confirmation_view, kwargs=kwargs), with_domain=True)
+ return node.construct_url(subpath=self.reverse(confirmation_view, kwargs=kwargs), with_domain=True, secure=secure)
def send_confirmation_email(self, subject, email, page, extra_context):
text_content = page.render_to_string(extra_context=extra_context)
def send_confirmation_email(self, subject, email, page, extra_context):
text_content = page.render_to_string(extra_context=extra_context)
- 'link': self.make_confirmation_link('password_reset_confirm', token_generator, user, request.node),
+ 'link': self.make_confirmation_link('password_reset_confirm', token_generator, user, request.node, secure=request.is_secure()),
+ 'user': user,
+ 'site': current_site,
+ 'request': request,
+
+ # Deprecated... leave in for backwards-compatibility
'username': user.username
}
self.send_confirmation_email('Confirm password reset for account at %s' % current_site.domain, user.email, self.password_reset_confirmation_email, context)
messages.add_message(request, messages.SUCCESS, "An email has been sent to the address you provided with details on resetting your password.", fail_silently=True)
return HttpResponseRedirect('')
else:
'username': user.username
}
self.send_confirmation_email('Confirm password reset for account at %s' % current_site.domain, user.email, self.password_reset_confirmation_email, context)
messages.add_message(request, messages.SUCCESS, "An email has been sent to the address you provided with details on resetting your password.", fail_silently=True)
return HttpResponseRedirect('')
else:
if token_generator.check_token(user, token):
if request.method == 'POST':
if token_generator.check_token(user, token):
if request.method == 'POST':
if form.is_valid():
form.save()
messages.add_message(request, messages.SUCCESS, "Password reset successful.")
return HttpResponseRedirect(self.reverse('login', node=request.node))
else:
if form.is_valid():
form.save()
messages.add_message(request, messages.SUCCESS, "Password reset successful.")
return HttpResponseRedirect(self.reverse('login', node=request.node))
else:
def password_change(self, request, extra_context=None):
if request.method == 'POST':
def password_change(self, request, extra_context=None):
if request.method == 'POST':
if form.is_valid():
form.save()
messages.add_message(request, messages.SUCCESS, 'Password changed successfully.', fail_silently=True)
return HttpResponseRedirect('')
else:
if form.is_valid():
form.save()
messages.add_message(request, messages.SUCCESS, 'Password changed successfully.', fail_silently=True)
return HttpResponseRedirect('')
else:
register_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_register_related', blank=True, null=True)
register_confirmation_email = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_register_confirmation_email_related', blank=True, null=True)
register_page = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_register_related', blank=True, null=True)
register_confirmation_email = models.ForeignKey(Page, related_name='%(app_label)s_%(class)s_register_confirmation_email_related', blank=True, null=True)
- 'link': self.make_confirmation_link('register_confirm', token_generator, user, request.node)
+ 'link': self.make_confirmation_link('register_confirm', token_generator, user, request.node, secure=request.is_secure()),
+ 'user': user,
+ 'site': current_site,
+ 'request': request
self.send_confirmation_email('Confirm account creation at %s' % current_site.name, user.email, self.register_confirmation_email, context)
messages.add_message(request, messages.SUCCESS, 'An email has been sent to %s with details on activating your account.' % user.email, fail_silently=True)
return HttpResponseRedirect(request.node.get_absolute_url())
else:
self.send_confirmation_email('Confirm account creation at %s' % current_site.name, user.email, self.register_confirmation_email, context)
messages.add_message(request, messages.SUCCESS, 'An email has been sent to %s with details on activating your account.' % user.email, fail_silently=True)
return HttpResponseRedirect(request.node.get_absolute_url())
else:
- 'link': self.make_confirmation_link('email_change_confirm', token_generator, request.user, request.node, token_args=[email], reverse_kwargs={'email': email.replace('@', '+')})
+ 'link': self.make_confirmation_link('email_change_confirm', token_generator, request.user, request.node, token_args=[email], reverse_kwargs={'email': email.replace('@', '+')}, secure=request.is_secure()),
+ 'user': request.user,
+ 'site': current_site,
+ 'request': request
self.send_confirmation_email('Confirm account email change at %s' % current_site.domain, email, self.email_change_confirmation_email, context)
message = "An email has be sent to %s to confirm the email%s." % (email, bool(request.user.email) and " change" or "")
self.send_confirmation_email('Confirm account email change at %s' % current_site.domain, email, self.email_change_confirmation_email, context)
message = "An email has be sent to %s to confirm the email%s." % (email, bool(request.user.email) and " change" or "")