예제 #1
0
파일: web.py 프로젝트: jmorenoamor/grano
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.")
예제 #2
0
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'))
예제 #3
0
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'))
예제 #4
0
파일: web.py 프로젝트: mihi-tr/grano
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.')
예제 #5
0
파일: web.py 프로젝트: pudo-attic/grano-old
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.')
예제 #6
0
파일: web.py 프로젝트: jmorenoamor/grano
def load_account(name):
    return Account.by_name(name)
예제 #7
0
파일: web.py 프로젝트: pudo-attic/grano-old
def load_account(name):
    return Account.by_name(name)
예제 #8
0
 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
예제 #9
0
 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