# -*- coding: utf-8 -*-
from __future__ import annotations

from django.contrib.auth.mixins import AccessMixin

from .checks import is_authenticated_and_active_account


class AccountRequiredMixin(AccessMixin):
    def dispatch(self, request, *args, **kwargs):
        if is_authenticated_and_active_account(self.request.user) is False:
            return self.handle_no_permission()

        return super().dispatch(request, *args, **kwargs)
