Ejemplo n.º 1
0
def get_current_user_id_unsafe():
    """Get the user_id a new user would get for the current auth credentials.

    Typically, this is the user_id of the current, logged in user. However,
    it's really important to note that it may correspond to a user_id that
    doesn't belong to any user. For example, if third-party
    credentials are provided (e.g. valid Facebook tokens), and we
    resolve them to point to an existing, different user (through e-mail
    e-mail matching or other means), this would return a user_id value
    that's constructed from the Facebook credentials, even though
    the user_id of the current logged in user is something different.

    Returns:
        A string value for the user_id, or None if no valid auth credentials
        are detected in the request.
    """

    user_id = None

    oauth_map = current_oauth_map()
    if oauth_map:
        user_id = _get_current_user_id_from_oauth_map(oauth_map)

    if not user_id and allow_cookie_based_auth():
        user_id = _get_current_user_id_from_cookies_unsafe()

    return user_id
Ejemplo n.º 2
0
def get_current_user_id_unsafe():
    """Get the user_id a new user would get for the current auth credentials.

    Typically, this is the user_id of the current, logged in user. However,
    it's really important to note that it may correspond to a user_id that
    doesn't belong to any user. For example, if third-party
    credentials are provided (e.g. valid Facebook tokens), and we
    resolve them to point to an existing, different user (through e-mail
    e-mail matching or other means), this would return a user_id value
    that's constructed from the Facebook credentials, even though
    the user_id of the current logged in user is something different.

    Returns:
        A string value for the user_id, or None if no valid auth credentials
        are detected in the request.
    """

    user_id = None

    oauth_map = current_oauth_map()
    if oauth_map:
        user_id = _get_current_user_id_from_oauth_map(oauth_map)

    if not user_id and allow_cookie_based_auth():
        user_id = _get_current_user_id_from_cookies_unsafe()

    return user_id
Ejemplo n.º 3
0
def get_current_user_id():
    user_id = None

    oauth_map = current_oauth_map()
    if oauth_map:
        user_id = get_current_user_id_from_oauth_map(oauth_map)

    if not user_id and allow_cookie_based_auth():
        user_id = get_current_user_id_from_cookies_unsafe()

    return user_id
Ejemplo n.º 4
0
def get_current_user_id():
    user_id = None

    oauth_map = current_oauth_map()
    if oauth_map:
        user_id = get_current_user_id_from_oauth_map(oauth_map)

    if not user_id and allow_cookie_based_auth():
        user_id = get_current_user_id_from_cookies_unsafe()

    return user_id
Ejemplo n.º 5
0
def get_current_user_id_unsafe(cookies=None):
    """Get the user_id a new user would get for the current auth credentials.

    Typically, this is the user_id of the current, logged in user.

    Returns:
        A string value for the user_id, or None if no valid auth credentials
        are detected in the request.
    """

    user_id = None

    oauth_map = current_oauth_map()
    if oauth_map:
        user_id = _get_current_user_id_from_oauth_map(oauth_map)

    if not user_id and allow_cookie_based_auth():
        user_id = _get_current_user_id_from_cookies_unsafe(cookies=cookies)

    return user_id