예제 #1
0
        private UserAuth GetUserAuthByUserName(IRedisClientFacade redis, string userNameOrEmail)
        {
            var isEmail = userNameOrEmail.Contains("@");
            var userId  = isEmail
                ? redis.GetValueFromHash(IndexEmailToUserId, userNameOrEmail)
                : redis.GetValueFromHash(IndexUserNameToUserId, userNameOrEmail);

            return(userId == null ? null : redis.As <UserAuth>().GetById(userId));
        }
예제 #2
0
        private UserAuth GetUserAuth(IRedisClientFacade redis, string userAuthId)
        {
            long longId;

            if (userAuthId == null || !long.TryParse(userAuthId, out longId))
            {
                return(null);
            }

            return(redis.As <UserAuth>().GetById(longId));
        }
예제 #3
0
        private UserAuth GetUserAuth(IRedisClientFacade redis, IAuthSession authSession, IOAuthTokens tokens)
        {
            if (!authSession.UserAuthId.IsNullOrEmpty())
            {
                var userAuth = GetUserAuth(redis, authSession.UserAuthId);
                if (userAuth != null)
                {
                    return(userAuth);
                }
            }
            if (!authSession.UserAuthName.IsNullOrEmpty())
            {
                var userAuth = GetUserAuthByUserName(authSession.UserAuthName);
                if (userAuth != null)
                {
                    return(userAuth);
                }
            }

            if (tokens == null || tokens.Provider.IsNullOrEmpty() || tokens.UserId.IsNullOrEmpty())
            {
                return(null);
            }

            var oAuthProviderId = GetAuthProviderByUserId(redis, tokens.Provider, tokens.UserId);

            if (!oAuthProviderId.IsNullOrEmpty())
            {
                var oauthProvider = redis.As <UserOAuthProvider>().GetById(oAuthProviderId);
                if (oauthProvider != null)
                {
                    return(redis.As <UserAuth>().GetById(oauthProvider.UserAuthId));
                }
            }
            return(null);
        }
        private UserAuth GetUserAuth(IRedisClientFacade redis, IAuthSession authSession, IOAuthTokens tokens)
        {
            if (!authSession.UserAuthId.IsNullOrEmpty())
            {
                var userAuth = GetUserAuth(redis, authSession.UserAuthId);
                if (userAuth != null) return userAuth;
            }
            if (!authSession.UserAuthName.IsNullOrEmpty())
            {
                var userAuth = GetUserAuthByUserName(authSession.UserAuthName);
                if (userAuth != null) return userAuth;
            }

            if (tokens == null || tokens.Provider.IsNullOrEmpty() || tokens.UserId.IsNullOrEmpty()) return null;

            var oAuthProviderId = GetAuthProviderByUserId(redis, tokens.Provider, tokens.UserId);
            if (!oAuthProviderId.IsNullOrEmpty())
            {
                var oauthProvider = redis.As<UserOAuthProvider>().GetById(oAuthProviderId);
                if (oauthProvider != null)
                    return redis.As<UserAuth>().GetById(oauthProvider.UserAuthId);
            }
            return null;
        } 
        private UserAuth GetUserAuth(IRedisClientFacade redis, string userAuthId)
        {
            long longId;
            if (userAuthId == null || !long.TryParse(userAuthId, out longId)) return null;

            return redis.As<UserAuth>().GetById(longId);
        }
        private UserAuth GetUserAuthByUserName(IRedisClientFacade redis, string userNameOrEmail)
        {
            var isEmail = userNameOrEmail.Contains("@");
            var userId = isEmail
                ? redis.GetValueFromHash(IndexEmailToUserId, userNameOrEmail)
                : redis.GetValueFromHash(IndexUserNameToUserId, userNameOrEmail);

            return userId == null ? null : redis.As<UserAuth>().GetById(userId);
        }