def get_limit_login_error_message(self, username, ip): times_up = settings.SECURITY_LOGIN_LIMIT_COUNT times_failed = get_login_failed_count(username, ip) times_try = int(times_up) - int(times_failed) block_time = settings.SECURITY_LOGIN_LIMIT_TIME if times_try <= 0: error_message = self.error_messages['block_login'] error_message = error_message.format(block_time) else: error_message = self.error_messages['limit_login'] error_message = error_message.format( times_try=times_try, block_time=block_time, ) return error_message
def __init__(self, error, username, ip, request): super().__init__(error=error, username=username, ip=ip, request=request) times_up = settings.SECURITY_LOGIN_LIMIT_COUNT times_failed = get_login_failed_count(username, ip) times_try = int(times_up) - int(times_failed) block_time = settings.SECURITY_LOGIN_LIMIT_TIME default_msg = invalid_login_msg.format(times_try=times_try, block_time=block_time) if error == reason_password_failed: self.msg = default_msg else: self.msg = reason_choices.get(error, default_msg)