예제 #1
0
def authorize():
    """
    Use information from github oauth log in to either create a new user or log in as an existing user.
    """
    resp = git_auth.authorized_response()
    user_info = git_auth.get('user', token=(resp["access_token"], )).data
    u = db_session.query(User).filter(User.email == user_info['email']).first()
    if not u:
        u = User(user_info['login'], user_info['email'])
        db_session.add(u)
        db_session.commit()
    login_user(u, remember=True)
    return redirect(url_for('index'))
예제 #2
0
def authorize():
    """
    Use information from github oauth log in to either create a new user or log in as an existing user.
    """
    resp = git_auth.authorized_response()
    user_info = git_auth.get('user', token=(resp["access_token"],)).data
    u = db_session.query(User).filter(User.email == user_info['email']).first()
    if not u:
        u = User(user_info['login'], user_info['email'])
        db_session.add(u)
        db_session.commit()
    login_user(u, remember=True)
    return redirect(url_for('index'))
예제 #3
0
 def wrapper(*a, **kw):
     if db_session.query(Admin).filter(
             Admin.id == current_user.id).first() is None:
         return redirect(url_for('index'))
     return f(*a, **kw)
예제 #4
0
def user_loader(user_id):
    return db_session.query(User).filter(User.id == user_id).one()
예제 #5
0
 def wrapper(*a, **kw):
     if db_session.query(Admin).filter(Admin.id == current_user.id).first() is None:
         return redirect(url_for('index'))
     return f(*a, **kw)
예제 #6
0
def user_loader(user_id):
    return db_session.query(User).filter(User.id == user_id).one()