Exemplo n.º 1
0
def remove_session(session_struct):
    session_key = session_struct.get('key', '')
    if not session_key:
        return

    #util.db_update('user_info', {'session_key': session_key}, {'session_key': ''}, multi=True)
    #util.db_update('user_info', {'session_key2': session_key}, {'session_key2': ''}, multi=True)
    util.db_remove('session_user_map', {"session_key": session_key})
Exemplo n.º 2
0
def remove_session(session_struct):
    session_key = session_struct.get('key', '')
    if not session_key:
        return

    #util.db_update('user_info', {'session_key': session_key}, {'session_key': ''}, multi=True)
    #util.db_update('user_info', {'session_key2': session_key}, {'session_key2': ''}, multi=True)
    util.db_remove('session_user_map', {"session_key": session_key})
Exemplo n.º 3
0
def _redirect_register(state):
    login_info = util.db_find_one('login_info', {"state": state})
    util.db_remove('login_info', {"state": state})

    path_qs = login_info.get('url', '')

    redirect_url = cfg.config.get('sitename', 'localhost') + path_qs

    cfg.logger.warning('to redirect: redirect_url: %s', redirect_url)

    redirect(redirect_url)
Exemplo n.º 4
0
def save_session_user_map(session_struct, user_id):
    session_key = session_struct.get('key', '')
    if not session_key:
        return

    util.db_update('session_user_map', {"session_key": session_key}, {'the_timestamp': session_struct.get('the_timestamp', 0), 'user_id': user_id})

    is_cron_remove_expire = cfg.config.get('is_cron_remove_expire', True)
    if not is_cron_remove_expire:
        expire_timestamp_session = cfg.config.get('expire_unix_timestamp_session', EXPIRE_UNIX_TIMESTAMP_SESSION) * 1000
        util.db_remove('session_user_map', {"the_timestamp": expire_timestamp_session})
Exemplo n.º 5
0
def _redirect_register(state):
    login_info = util.db_find_one('login_info', {"state": state})
    util.db_remove('login_info', {"state": state})

    path_qs = login_info.get('url', '')

    redirect_url = cfg.config.get('sitename', 'localhost') + path_qs

    cfg.logger.warning('to redirect: redirect_url: %s', redirect_url)

    redirect(redirect_url)
Exemplo n.º 6
0
def save_session_user_map(session_struct, user_id):
    session_key = session_struct.get('key', '')
    if not session_key:
        return

    util.db_update('session_user_map', {"session_key": session_key}, {
        'the_timestamp': session_struct.get('the_timestamp', 0),
        'user_id': user_id
    })

    is_cron_remove_expire = cfg.config.get('is_cron_remove_expire', True)
    if not is_cron_remove_expire:
        expire_timestamp_session = cfg.config.get(
            'expire_unix_timestamp_session',
            EXPIRE_UNIX_TIMESTAMP_SESSION) * 1000
        util.db_remove('session_user_map',
                       {"the_timestamp": expire_timestamp_session})
Exemplo n.º 7
0
def _login(client_id, scope, register_uri, authorization_base_url, request,
           params):
    (session_struct, session_struct2) = util_user.process_session(request)
    cfg.logger.debug('session_struct: %s session_struct2: %s', session_struct,
                     session_struct2)

    the_path = params.get('url', '')
    the_timestamp = util.get_timestamp()

    cfg.logger.debug('params: %s the_path: %s', params, the_path)

    the_auth = OAuth2Session(client_id, scope=scope, redirect_uri=register_uri)

    authorization_url, state = the_auth.authorization_url(
        authorization_base_url, approval_prompt="auto")

    util.db_insert(
        'login_info', {
            "state": state,
            "the_timestamp": the_timestamp,
            "params": params,
            "url": the_path
        })

    is_cron_remove_expire = cfg.config.get('is_cron_remove_expire', True)
    if not is_cron_remove_expire:
        expire_timestamp_session = cfg.config.get(
            'expire_unix_timestamp_session',
            EXPIRE_UNIX_TIMESTAMP_SESSION) * 1000
        util.db_remove('login_info', {
            "the_timestamp": {
                "$lt": the_timestamp - expire_timestamp_session
            }
        })

    cfg.logger.debug(
        'after authorization_url: authorization_url: %s state: %s',
        authorization_url, state)

    redirect(authorization_url)
Exemplo n.º 8
0
def _login(client_id, scope, register_uri, authorization_base_url, request, params):
    (session_struct, session_struct2) = util_user.process_session(request)
    cfg.logger.debug('session_struct: %s session_struct2: %s', session_struct, session_struct2)

    the_path = params.get('url', '')
    the_timestamp = util.get_timestamp()

    cfg.logger.debug('params: %s the_path: %s', params, the_path)

    the_auth = OAuth2Session(client_id, scope=scope, redirect_uri=register_uri)

    authorization_url, state = the_auth.authorization_url(authorization_base_url, approval_prompt="auto")

    util.db_insert('login_info', {"state": state, "the_timestamp": the_timestamp, "params": params, "url": the_path})

    is_cron_remove_expire = cfg.config.get('is_cron_remove_expire', True)
    if not is_cron_remove_expire:
        expire_timestamp_session = cfg.config.get('expire_unix_timestamp_session', EXPIRE_UNIX_TIMESTAMP_SESSION) * 1000
        util.db_remove('login_info', {"the_timestamp": {"$lt": the_timestamp - expire_timestamp_session}})

    cfg.logger.debug('after authorization_url: authorization_url: %s state: %s', authorization_url, state)

    redirect(authorization_url)
Exemplo n.º 9
0
def remove_user(user_id):
    util.db_remove('user_info', {"user_id": user_id})
Exemplo n.º 10
0
def remove_user(user_id):
    util.db_remove('user_info', {"user_id": user_id})