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'))
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'))
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)
def user_loader(user_id): return db_session.query(User).filter(User.id == user_id).one()
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)