Пример #1
0
def server_oauth_logout():
    """Revoke user authentication and deletes user's session information.

    Returns:
      JSON response detailing a success or failed logout.
    """
    try:
        credentials = G_CREDENTIAL_STORAGE.get()
        if credentials is None:
            response = jsonify(message='Current user not connected.')
            response.status_code = 401
            return response

        credentials.revoke(httplib2.Http())
    except err:
        print err
    finally:
        if G_CREDENTIAL_STORAGE.get() is not None:
            G_CREDENTIAL_STORAGE.delete()
        del session['gplus_id']
        del session['username']
        del session['email']
        del session['picture']
        del session['state']
        del session['user_id']

    flash('Successfully logged out')
    return jsonify(message='Successfully disconnected.')
def server_oauth_logout():
    """Revoke user authentication and deletes user's session information.

    Returns:
      JSON response detailing a success or failed logout.
    """
    try:
        credentials = G_CREDENTIAL_STORAGE.get()
        if credentials is None:
            response = jsonify(message='Current user not connected.')
            response.status_code = 401
            return response

        credentials.revoke(httplib2.Http())
    except err:
        print err
    finally:
        if G_CREDENTIAL_STORAGE.get() is not None:
            G_CREDENTIAL_STORAGE.delete()
        del session['gplus_id']
        del session['username']
        del session['email']
        del session['picture']
        del session['state']
        del session['user_id']

    flash('Successfully logged out')
    return jsonify(message='Successfully disconnected.')
Пример #3
0
    userinfo = oauth_service.userinfo().get().execute()

    email = userinfo['email']
    username = userinfo['name']
    session['username'] = username
    session['picture'] = userinfo['picture']
    session['email'] = email
    session['gplus_id'] = gplus_id

    # create a user account if none associated with email

    user_id = get_user_id(email)
    if user_id is None:
        user_id = create_user(session)
    session['user_id'] = user_id
    G_CREDENTIAL_STORAGE.put(credentials)

    flash('You\'re now logged in as {0}'.format(username))
    return jsonify(userinfo)


@app.route('/logout')
def server_oauth_logout():
    """Revoke user authentication and deletes user's session information.

    Returns:
      JSON response detailing a success or failed logout.
    """
    try:
        credentials = G_CREDENTIAL_STORAGE.get()
        if credentials is None:
    userinfo = oauth_service.userinfo().get().execute()

    email = userinfo['email']
    username = userinfo['name']
    session['username'] = username
    session['picture'] = userinfo['picture']
    session['email'] = email
    session['gplus_id'] = gplus_id

    # create a user account if none associated with email

    user_id = get_user_id(email)
    if user_id is None:
        user_id = create_user(session)
    session['user_id'] = user_id
    G_CREDENTIAL_STORAGE.put(credentials)

    flash('You\'re now logged in as {0}'.format(username))
    return jsonify(userinfo)


@app.route('/logout')
def server_oauth_logout():
    """Revoke user authentication and deletes user's session information.

    Returns:
      JSON response detailing a success or failed logout.
    """
    try:
        credentials = G_CREDENTIAL_STORAGE.get()
        if credentials is None: