def basic_authentication(): """ Attempt HTTP basic authentication on a per-request basis. """ if "Authorization" in request.headers: authorization = request.headers.get("Authorization") authorization = authorization.split(" ", 1)[-1] name, password = authorization.decode("base64").split(":", 1) account = Account.by_name(name) if account is None or not account.validate_password(password) or not login_user(account): raise Unauthorized("Invalid username or password.")
def login_save(): """ Create an account based on the sign-up form. """ data = request_content(request) account = Account.by_name(data.get('name')) if not account \ or not account.validate_password(data.get('password')) \ or not login_user(account): return error_fill(login_form(), data, {'name': 'Invalid username or password!'}) flash("Welcome back, %s!" % account.display_name, 'success') return redirect(url_for('home.index'))
def login_save(): """ Create an account based on the sign-up form. """ data = request_content(request) account = Account.by_name(data.get('name')) if not account \ or not account.validate_password(data.get('password')) \ or not login_user(account): return error_fill(login_form(), data, {'name': 'Invalid username or password!'}) flash("Welcome back, %s!" % account.display_name, 'success') return redirect(url_for('home.index'))
def basic_authentication(): """ Attempt HTTP basic authentication on a per-request basis. """ if 'Authorization' in request.headers: authorization = request.headers.get('Authorization') authorization = authorization.split(' ', 1)[-1] name, password = authorization.decode('base64').split(':', 1) account = Account.by_name(name) if account is None \ or not account.validate_password(password) \ or not login_user(account): raise Unauthorized('Invalid username or password.')
def basic_authentication(): """ Attempt HTTP basic authentication on a per-request basis. """ if 'Authorization' in request.headers: authorization = request.headers.get('Authorization') authorization = authorization.split(' ', 1)[-1] name, password = authorization.decode('base64').split(':', 1) account = Account.by_name(name) if account is None \ or not account.validate_password(password) \ or not login_user(account): raise Unauthorized('Invalid username or password.')
def load_account(name): return Account.by_name(name)
def load_account(name): return Account.by_name(name)
def _check(value): if context.account and context.account.name == value: return True if Account.by_name(value) is not None: return "This account name is already in use, please choose another." return True
def _check(value): if context.account and context.account.name == value: return True if Account.by_name(value) is not None: return "This account name is already in use, please choose another." return True