def login(username, password):
"""
Authenticates a user.
"""
# Read in submitted username and password
validate(user_login_schema, {
"username": username,
"password": password
})
user = safe_fail(api.user.get_user, name=username)
if user is None:
raise WebException("Incorrect username.")
if user.get("disabled", False):
raise WebException("This account has been disabled.")
if confirm_password(password, user['password_hash']):
if debug_disable_general_login:
if session.get('debugaccount', False):
raise WebException("Correct credentials! But the game has not started yet...")
if user['uid'] is not None:
session['uid'] = user['uid']
session.permanent = True
else:
raise WebException("Login Error")
else:
raise WebException("Incorrect Password")
评论列表
文章目录