public static IAuthSession GetUntypedSession(this ICacheClient cache,
                                                     IRequest httpReq = null, IResponse httpRes = null)
        {
            var sessionKey = GetSessionKey(httpReq);

            if (sessionKey != null)
            {
                var userSession = cache.Get <IAuthSession>(sessionKey);
                if (!Equals(userSession, default(AuthUserSession)))
                {
                    return(userSession);
                }
            }

            if (sessionKey == null)
            {
                SessionFeature.CreateSessionIds(httpReq, httpRes);
            }

            var unAuthorizedSession = (IAuthSession)typeof(AuthUserSession).CreateInstance();

            return(unAuthorizedSession);
        }
Пример #2
0
        public static async Task <IAuthSession> GetUntypedSessionAsync(this ICacheClientAsync cache,
                                                                       IRequest httpReq = null, IResponse httpRes = null, CancellationToken token = default)
        {
            var sessionKey = GetSessionKey(httpReq);

            if (sessionKey != null)
            {
                var userSession = await cache.GetAsync <IAuthSession>(sessionKey, token);

                if (!Equals(userSession, default(AuthUserSession)))
                {
                    return(userSession);
                }
            }

            if (sessionKey == null)
            {
                SessionFeature.CreateSessionIds(httpReq, httpRes);
            }

            var unAuthorizedSession = (IAuthSession)typeof(AuthUserSession).CreateInstance();

            return(unAuthorizedSession);
        }
        public static string GetOrCreateSessionId(this IRequest httpReq)
        {
            var sessionId = httpReq.GetSessionId();

            return(sessionId ?? SessionFeature.CreateSessionIds(httpReq));
        }