# Path: doberman/decorators.py
# def watch_login(func):
#     """
#     Decorator @watch_login
#     :param func:
#     :return:
#     """
#     @wraps(func)
#     def decorated_login(request, *args, **kwargs):
# 
#         response = func(request, *args, **kwargs)
# 
#         lockout = AccessAttempt(request, response)
#         user_access = lockout.check_failed_login()
# 
#         if user_access.is_locked or lockout.is_ip_banned:
#             return lockout.get_lockout_response()
# 
#         return response
# 
#     return decorated_login


from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth import login as auth_login
from django.shortcuts import redirect
from django.views.generic import FormView
from django.utils.translation import gettext as _
from django.forms.utils import ErrorList
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from doberman.decorators import watch_login
from accounts.forms import *
# -*- coding: utf-8 -*-




User = get_user_model()


class LoginUserView(FormView):
    """
    Login User View
    @watch_logins
    """
    form_class = LoginUserForm
    template_name = 'accounts/login.html'

    @method_decorator(csrf_protect)
    @method_decorator(never_cache)

# Path: doberman/decorators.py
# def watch_login(func):
#     """
#     Decorator @watch_login
#     :param func:
#     :return:
#     """
#     @wraps(func)
#     def decorated_login(request, *args, **kwargs):
# 
#         response = func(request, *args, **kwargs)
# 
#         lockout = AccessAttempt(request, response)
#         user_access = lockout.check_failed_login()
# 
#         if user_access.is_locked or lockout.is_ip_banned:
#             return lockout.get_lockout_response()
# 
#         return response
# 
#     return decorated_login


# Path: doberman/example/doberman_example/accounts/views.py
from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth import login as auth_login
from django.shortcuts import redirect
from django.views.generic import FormView
from django.utils.translation import gettext as _
from django.forms.utils import ErrorList
from django.utils.decorators import method_decorator
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from doberman.decorators import watch_login
from accounts.forms import *

# -*- coding: utf-8 -*-




User = get_user_model()


class LoginUserView(FormView):
    """
    Login User View
    @watch_logins
    """
    form_class = LoginUserForm
    template_name = 'accounts/login.html'

    @method_decorator(csrf_protect)
    @method_decorator(never_cache)

    @method_decorator(watch_login)