Search code examples
pythondjangoauthenticationaxes

django-axes not capturing failed login attempt on RPC


I use django-axes to capture the failed login but I thing this library uses the internal DB of django and my case the authentication is a RPC call. The code is:

urls.py

url(r'^$', watch_login(views.login.as_view()),name='login')

views.py

class login(Base):

def __init__(self):
    Base.__init__(self) 



def get(self, request):

        return render(request, 'templates/login.html', {'menu':self.menu})

@method_decorator(watch_login) 
def post(self,request):


        response = self.server.login(request.POST['username'],request.POST['password'])
        if(response['correct']==True):
            request.session['session_id']=response['sessionid']
            request.session['response']=response
            request.session.set_expiry(5)
            request.session['username']=request.POST['username']

            return redirect(reverse('home:IndexHome')) 
        else:


            return redirect(reverse('login'))

I don't know where the library caught the fail logins and I try a lot of variants to solve this trouble.

PD: I changed my settings.py too.

Thx.


Solution

  • Replace

    return render(request,'templates/login.html',status=302)
    

    instead of

    return redirect(reverse('login'))