def post(self, request, confirmation_key):
        confirmation = get_object_or_404(
            MergeAccountConfirmation,
            confirmation_key=confirmation_key)
        if confirmation.merge_with != request.user:
            raise PermissionDenied

        initial_user = confirmation.initial_user
        merge_with = confirmation.merge_with

        # Move emails
        for email in merge_with.emails.all():
            initial_user.emails.add(email)

        # Run a post merge hook
        run_hook('post-merge', initial_user, merge_with)

        confirmation.delete()

        # The current user is no longer valid
        logout(request)
        # The account is now obsolete and should be removed
        merge_with.delete()

        return redirect(self.success_url)
Example #2
0
 def get(self, request):
     user = request.user
     logout(request)
     next_url = request.GET.get(self.redirect_parameter, self.success_url)
     redirect_url = run_hook('post-logout-redirect', request, user, next_url)
     if redirect_url:
         return redirect(redirect_url)
     else:
         return redirect(next_url if next_url else '/')
 def get(self, request):
     user = request.user
     logout(request)
     redirect_url = run_hook('post-logout-redirect', user)
     if redirect_url:
         return redirect(redirect_url)
     else:
         if self.redirect_parameter in request.GET and request.GET[self.redirect_parameter]:
             return redirect(request.GET[self.redirect_parameter])
         else:
             return redirect(self.success_url)
Example #4
0
    def get(self, request):
        user = request.user
        logout(request)

        next_url = request.GET.get(self.redirect_parameter, self.success_url)
        if not is_safe_url(
            next_url,
            allowed_hosts=set(self.request.get_host())
        ):
            next_url = self.success_url

        redirect_url = run_hook('post-logout-redirect', request, user, next_url)
        if redirect_url:
            return redirect(redirect_url)
        else:
            return redirect(next_url if next_url else '/')
Example #5
0
    def clean(self):
        run_hook('pre-login', self)
        cleaned_data = super(AuthenticationForm, self).clean()

        return cleaned_data