Skip to content

Instantly share code, notes, and snippets.

@LuqiPan
Last active January 23, 2017 01:08
Show Gist options
  • Save LuqiPan/13561825bc431e5c8facf7d2fe51a189 to your computer and use it in GitHub Desktop.
Save LuqiPan/13561825bc431e5c8facf7d2fe51a189 to your computer and use it in GitHub Desktop.
Log Driven Development
def login(login, password):
"""This function tries to log the user in and populate the session
Args:
login (str): The login of the user
password (str): The (hashed) password of the user
Returns:
bool: The result of login. True for success, False otherwise
"""
user = fetch_user(login, password)
if not user:
return False
request.session['id'] = user.id
# TODO (1/1/2003): implement a better way to handle VIP users
if request.POST['VIP_KEY'] == '5fa3e7a21e34714b44720836573a71ce':
request.session['is_vip'] = True
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment