from django.conf import settings
from django.http import HttpResponseRedirect

DETACH_PATH = '/user/detach'
ACTIVATE_PATH = '/user/activate'

class DetachMiddleware(object):
    def process_request(self, request):
        if not request.path == '/login/' \
                and not request.path.startswith('/api')  \
                and not request.user.is_anonymous:

            if not request.user.is_native:
                if not (request.path == DETACH_PATH
                        or request.path.startswith('/logout')):
                    return HttpResponseRedirect(DETACH_PATH)
            elif not request.user.is_mail_verified \
                    and not (ACTIVATE_PATH in request.path
                             or request.path.startswith('/logout')):
                return HttpResponseRedirect(ACTIVATE_PATH)
from django.conf import settings
from django.http import HttpResponseRedirect

DETACH_PATH = '/user/detach'
ACTIVATE_PATH = '/user/activate'

class DetachMiddleware(object):
    def process_request(self, request):
        if not request.path == '/login/' \
                and not request.path.startswith('/api')  \
                and not request.user.is_anonymous:

            if not request.user.is_native:
                if not (request.path == DETACH_PATH
                        or request.path.startswith('/logout')):
                    return HttpResponseRedirect(DETACH_PATH)
            elif not request.user.is_mail_verified \
                    and not (request.path.startswith(ACTIVATE_PATH)
                             or request.path.startswith('/logout')):
                return HttpResponseRedirect(ACTIVATE_PATH)
Revert trying to fix activation redirection bug
Revert trying to fix activation redirection bug

This reverts commit c2d63335062abea4cece32bd01132bcf8dce44f2.
It seems like the commit doesn't actually do anything to alleviate the
bug. Since it's also more lenient with its checks, I'll rather revert
it.
