Commits

Michael Elsdörfer committed 9d09b93

The Backend.activate method can now return extra context to be used by the view. This allows a custom backend to implement an activation process in which the user is provided with a form to enter the activiation key, rather than it needing to be passed through the url.

Comments (0)

Files changed (2)

registration/backends/default/__init__.py

         Given an an activation key, look up and activate the user
         account corresponding to that key (if possible).
 
+        The return value should be a 2-tuple (new-user, extra_context).
+        ``None`` can be given for the user if activation failed.
+
         After successful activation, the signal
         ``registration.signals.user_activated`` will be sent, with the
         newly activated ``User`` as the keyword argument ``user`` and
             signals.user_activated.send(sender=self.__class__,
                                         user=activated,
                                         request=request)
-        return activated
+        return activated, {}
 
     def registration_allowed(self, request):
         """

registration/views.py

 
     """
     backend = get_backend(backend)
-    account = backend.activate(request, **kwargs)
+    account, backend_ctx = backend.activate(request, **kwargs)
 
     if account:
         if on_success:
     kwargs.update({
         'expiration_days': settings.ACCOUNT_ACTIVATION_DAYS,
     })
+    kwargs.update(backend_ctx)
     return render_to_response(template_name,
                               kwargs,
                               context_instance=context)