def deny( self ): client = Client( self.request ) if client.is_banned(): return HttpResponse( status=403 ) else: context = { 'title': "UNIFI", } return render( self.request, "login/login.html", context )
def deny(self): client = Client(self.request) if client.is_banned(): return HttpResponse(status=403) else: context = { 'title': "UNIFI", } return render(self.request, "login/login.html", context)
def deny( self ): client = Client( self.request ) if client.is_banned(): return HttpResponse( status=403 ) else: return self.dialog( title = "Not Authenticated", message = "Velkommen til UNIFI, du er ikke pålogget. " + \ "For å logge deg på benytt universitetets " + \ "innloggingsportal." )
def deny(self): client = Client(self.request) if client.is_banned(): return HttpResponse(status=403) else: return self.dialog( title = "Not Authenticated", message = "Velkommen til UNIFI, du er ikke pålogget. " + \ "For å logge deg på benytt universitetets " + \ "innloggingsportal." )
def deny( self ): # fetching the provided data client = Client( self.request ) username = self.request.POST.get( "username" ) password = self.request.POST.get( "password" ) if not password: return self.dialog( message="Your login attempt lacks password" ) # see if client has had previous failed attempts to login failed_attempts = Attempt.objects.filter( address=client.address ) if client.is_banned(): return self.dialog( message="Your address has been blocked for further login attempts. " + \ "Please wait %s seconds before you try again." \ % ( BAN_PERIOD_MINUTES - client.banned_since() ) ) else: # fetching user user = auth.authenticate( username=username, password=password ) # logging the user in if user: # remove all the failed attempts attempts = Attempt.objects.filter( address=client.address ) if attempts.count() > 0: attempts.delete() # create a session auth.login( self.request, user ) else: # register a failed attempt attempt = Attempt( address=client.address, username=username ) attempt.save() return redirect( "/" )
def deny(self): # fetching the provided data client = Client(self.request) username = self.request.POST.get("username") password = self.request.POST.get("password") if not password: return self.dialog(message="Your login attempt lacks password") # see if client has had previous failed attempts to login failed_attempts = Attempt.objects.filter(address=client.address) if client.is_banned(): return self.dialog( message="Your address has been blocked for further login attempts. " + \ "Please wait %s seconds before you try again." \ % ( BAN_PERIOD_MINUTES - client.banned_since() ) ) else: # fetching user user = auth.authenticate(username=username, password=password) # logging the user in if user: # remove all the failed attempts attempts = Attempt.objects.filter(address=client.address) if attempts.count() > 0: attempts.delete() # create a session auth.login(self.request, user) else: # register a failed attempt attempt = Attempt(address=client.address, username=username) attempt.save() return redirect("/")