def create_session(user_id, scopes, jwt, secret=None):
    secret = secret or guid().replace('-', '')
    timeout = now() + SESSION_TIMEOUT
    session = Session(key=Session.create_key(secret),
                      user_id=user_id,
                      timeout=timeout,
                      scopes=scopes,
                      jwt=jwt)
    session.put()
    return secret, session
Beispiel #2
0
 def get_session(self):
     username = get_config(NAMESPACE).apple.iyo_username
     session = Session.list_active_user(username).get()
     if not session:
         logging.error(
             'No session found for %s! Login with this account to resolve the issue',
             username)
     return session
Beispiel #3
0
def get_itsyouonline_client_from_username(username):
    session = get_current_session()
    if not session or session.user_id != username:
        session = Session.create_key(username).get()
    if not session:
        raise Exception('No session found for %s' % username)
    jwt = session.jwt
    client = get_itsyouonline_client_from_jwt(jwt)
    return client
def friend_invite_result(rt_settings, request_id, params, response):
    user_detail = log_and_parse_user_details(params['user_details'])[0]
    username = get_iyo_username(user_detail)
    if user_detail.public_keys:
        deferred.defer(store_public_key, user_detail)
    deferred.defer(store_info_in_userdata, username, user_detail)
    deferred.defer(add_grant, username, Grants.PUBLIC)
    deferred.defer(add_user_to_public_role, user_detail)
    deferred.defer(populate_intercom_user, Session.create_key(username), user_detail)
def validate_session(secret):
    session = Session.create_key(secret).get()
    if not session:
        return None, None
    if session.timeout < now():
        session.key.delete()
        return None, None
    if session.timeout < now() + (SESSION_TIMEOUT / 2):
        deferred.defer(_update_session_timeout, secret)
    return session, session.user_id
def _refresh_sessions(user_id):
    for session_key in Session.list_active_user(user_id).iter(keys_only=True):
        deferred.defer(_refresh_session, session_key)
Beispiel #7
0
def _get_users():
    return Session.query()
def _get_all_sessions():
    return Session.query()
def _update_session_timeout(secret):
    session = Session.create_key(secret).get()
    if session and session.timeout < now() + (SESSION_TIMEOUT / 2):
        session.timeout = now() + SESSION_TIMEOUT
        session.put()
def drop_sessions_of_user(user_id):
    sessions = list(Session.query(Session.user_id == user_id))
    for chunk in chunks(sessions, 200):
        ndb.delete_multi(chunk)