def _get_user_id_from_session(session):
    """
    Get user's identifier from the session. It could be their id or username
    since both are unique.
    """
    user_sess_id = session.session_token.get("sub")
    if user_sess_id:
        try:
            user_sess_id = int(user_sess_id)
        except ValueError:
            # if we can't cast to an int, don't. could be username
            pass

    return user_sess_id