示例#1
0
def oauth_success():
    auth_code = request.args.get('code')
    credentials = flow.step2_exchange(auth_code)
    unique_id = credentials.id_token['sub']
    curr_user = UserDao.does_user_exist(unique_id)
    if not curr_user:
       curr_user = UserDao.add_user(unique_id,"",_generate_key(),credentials.access_token)
    session['logged_in_user'] = curr_user.id
    return redirect("/")
示例#2
0
def index():
    if 'logged_in_user' not in session:
        return redirect("/login")

    curr_user = UserDao.does_user_exist(session['logged_in_user'])
    res = {'api_key': curr_user.api_key}
    return render_template('index.html', res=res)
示例#3
0
def _valid_api_key(request):
    if 'Authorization' in request.headers:
        api_key = request.headers['Authorization']
        if UserDao.valid_api_key(api_key):
            return True
    return False