Ejemplo n.º 1
0
def api_authState():
    s = cookie.unchecked_get_value(_COOKIE_STATE)
    v = pkcollections.Dict(
        avatarUrl=None,
        displayName=None,
        needCompleteRegistration=s == _STATE_COMPLETE_REGISTRATION,
        isLoggedIn=_is_logged_in(s),
        method=cookie.unchecked_get_value(_COOKIE_METHOD),
        userName=None,
        visibleMethods=visible_methods,
    )
    u = cookie.unchecked_get_value(_COOKIE_USER)
    if v.isLoggedIn:
        r = auth_db.UserRegistration.search_by(uid=u)
        if r:
            v.displayName = r.display_name
        _method_auth_state(v, u)
    if pkconfig.channel_in('dev'):
        # useful for testing/debugging
        v.uid = u
    return http_reply.render_static(
        'auth-state',
        'js',
        pkcollections.Dict(auth_state=v),
    )
Ejemplo n.º 2
0
def _render_root_page(page, values):
    values.update(
        pkcollections.Dict(
            app_version=simulation_db.app_version(),
            source_cache_key=_source_cache_key(),
            static_files=simulation_db.static_libs(),
        ))
    return http_reply.render_static(page, 'html', values, cache_ok=True)
Ejemplo n.º 3
0
def api_authState():
    s = cookie.unchecked_get_value(_COOKIE_STATE)
    v = pkcollections.Dict(
        avatarUrl=None,
        displayName=None,
        guestIsOnlyMethod=not non_guest_methods,
        isGuestUser=False,
        isLoggedIn=_is_logged_in(s),
        isLoginExpired=False,
        method=cookie.unchecked_get_value(_COOKIE_METHOD),
        needCompleteRegistration=s == _STATE_COMPLETE_REGISTRATION,
        userName=None,
        visibleMethods=visible_methods,
    )
    u = cookie.unchecked_get_value(_COOKIE_USER)
    if v.isLoggedIn:
        if v.method == METHOD_GUEST:
            # currently only method to expire login
            v.displayName = _GUEST_USER_DISPLAY_NAME
            v.isGuestUser = True
            v.isLoginExpired = _METHOD_MODULES[METHOD_GUEST].is_login_expired()
            v.needCompleteRegistration = False
            v.visibleMethods = non_guest_methods
        else:
            r = auth_db.UserRegistration.search_by(uid=u)
            if r:
                v.displayName = r.display_name
        _method_auth_state(v, u)
    if pkconfig.channel_in('dev'):
        # useful for testing/debugging
        v.uid = u
    pkdc('state={}', v)
    return http_reply.render_static(
        'auth-state',
        'js',
        pkcollections.Dict(auth_state=v),
    )
Ejemplo n.º 4
0
def api_authState():
    return http_reply.render_static('auth-state', 'js',
                                    PKDict(auth_state=_auth_state()))