Skip to content

Commit

Permalink
Always define the task to store login attempt
Browse files Browse the repository at this point in the history
Adding function definitions based on config values makes testing hard.
The task function is always there, and we choose to call it depending on
config during runtime.
  • Loading branch information
bc Wong committed Jan 25, 2016
1 parent f904716 commit 831bb29
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions defender/tasks.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from . import config
from .data import store_login_attempt

# not sure how to get this to look better. ideally we want to dynamically
# apply the celery decorator based on the USE_CELERY setting.

if config.USE_CELERY:
from celery import shared_task
from celery import shared_task

@shared_task()
def add_login_attempt_task(user_agent, ip_address, username,
http_accept, path_info, login_valid):
""" Create a record for the login attempt """
store_login_attempt(user_agent, ip_address, username,
http_accept, path_info, login_valid)

@shared_task()
def add_login_attempt_task(user_agent, ip_address, username,
http_accept, path_info, login_valid):
""" Create a record for the login attempt """
store_login_attempt(user_agent, ip_address, username,
http_accept, path_info, login_valid)

0 comments on commit 831bb29

Please sign in to comment.