当前位置: 首页>>代码示例>>C#>>正文


C# IUserAuthRepository.GetUserOAuthProviders方法代码示例

本文整理汇总了C#中IUserAuthRepository.GetUserOAuthProviders方法的典型用法代码示例。如果您正苦于以下问题:C# IUserAuthRepository.GetUserOAuthProviders方法的具体用法?C# IUserAuthRepository.GetUserOAuthProviders怎么用?C# IUserAuthRepository.GetUserOAuthProviders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IUserAuthRepository的用法示例。


在下文中一共展示了IUserAuthRepository.GetUserOAuthProviders方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connecting_to_facebook_whilst_authenticated_connects_account

        public void Connecting_to_facebook_whilst_authenticated_connects_account(IUserAuthRepository userAuthRepository)
        {
            InitTest(userAuthRepository);

            var oAuthUserSession = requestContext.ReloadSession();

            oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);

            LoginWithFacebook(oAuthUserSession);

            var userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.UserName);

            Assert.That(userAuth.UserName, Is.EqualTo(registrationDto.UserName));

            var userAuthProviders = userAuthRepository.GetUserOAuthProviders(userAuth.Id.ToString(CultureInfo.InvariantCulture));
            Assert.That(userAuthProviders.Count, Is.EqualTo(1));
        }
开发者ID:jarrodalbert,项目名称:ServiceStack,代码行数:17,代码来源:OAuthUserSessionTests.cs

示例2: Does_persist_FacebookOAuth

        public void Does_persist_FacebookOAuth(IUserAuthRepository userAuthRepository)
        {
            InitTest(userAuthRepository);

            var serviceTokens = MockAuthHttpGateway.Tokens = facebookGatewayTokens;

            var oAuthUserSession = requestContext.ReloadSession();
            var authInfo = new Dictionary<string, string> { };
            var facebookAuth = GetFacebookAuthProvider();
            facebookAuth.OnAuthenticated(service, oAuthUserSession, facebookAuthTokens, authInfo);

            oAuthUserSession = requestContext.ReloadSession();

            Assert.That(oAuthUserSession.FacebookUserId, Is.EqualTo(serviceTokens.UserId));

            Assert.That(oAuthUserSession.UserAuthId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
            Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokens.FirstName));
            Assert.That(userAuth.LastName, Is.EqualTo(serviceTokens.LastName));
            Assert.That(userAuth.PrimaryEmail, Is.EqualTo(serviceTokens.Email));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(1));
            var authProvider = authProviders[0];
            Assert.That(authProvider.UserAuthId, Is.EqualTo(userAuth.Id));
            Assert.That(authProvider.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
            Assert.That(authProvider.FirstName, Is.EqualTo(serviceTokens.FirstName));
            Assert.That(authProvider.LastName, Is.EqualTo(serviceTokens.LastName));
            Assert.That(authProvider.Email, Is.EqualTo(serviceTokens.Email));
            Assert.That(authProvider.RequestToken, Is.Null);
            Assert.That(authProvider.RequestTokenSecret, Is.Null);
            Assert.That(authProvider.AccessToken, Is.Null);
            Assert.That(authProvider.AccessTokenSecret, Is.EqualTo(facebookAuthTokens.AccessTokenSecret));

            Console.WriteLine(authProviders.Dump());
        }
开发者ID:grammarware,项目名称:fodder,代码行数:39,代码来源:tests_ServiceStack_Common_Tests_OAuth_OAuthUserSessionTests.cs

示例3: Does_persist_TwitterOAuth

        public void Does_persist_TwitterOAuth(IUserAuthRepository userAuthRepository)
        {
            InitTest(userAuthRepository);

            MockAuthHttpGateway.Tokens = twitterGatewayTokens;

            var authInfo = new Dictionary<string, string> {
                {"user_id", "133371690876022785"},
                {"screen_name", "demisbellot"},				
            };

            var oAuthUserSession = requestContext.ReloadSession();

            var twitterAuth = GetTwitterAuthProvider();
            twitterAuth.OnAuthenticated(service, oAuthUserSession, twitterAuthTokens, authInfo);

            oAuthUserSession = requestContext.ReloadSession();

            Assert.That(oAuthUserSession.UserAuthId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo("Demis Bellot TW"));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(1));
            var authProvider = authProviders[0];
            Assert.That(authProvider.UserAuthId, Is.EqualTo(userAuth.Id));
            Assert.That(authProvider.DisplayName, Is.EqualTo("Demis Bellot TW"));
            Assert.That(authProvider.FirstName, Is.Null);
            Assert.That(authProvider.LastName, Is.Null);
            Assert.That(authProvider.RequestToken, Is.EqualTo(twitterAuthTokens.RequestToken));
            Assert.That(authProvider.RequestTokenSecret, Is.EqualTo(twitterAuthTokens.RequestTokenSecret));

            Console.WriteLine(authProviders.Dump());
        }
开发者ID:grammarware,项目名称:fodder,代码行数:36,代码来源:tests_ServiceStack_Common_Tests_OAuth_OAuthUserSessionTests.cs

示例4: Does_persist_TwitterOAuth

        public void Does_persist_TwitterOAuth(IUserAuthRepository userAuthRepository)
        {
            ((IClearable)userAuthRepository).Clear();

            var mockService = new Mock<IServiceBase>();
            mockService.Expect(x => x.TryResolve<IUserAuthRepository>())
                .Returns(userAuthRepository);

            var service = mockService.Object;

            MockAuthHttpGateway.Tokens = new OAuthTokens { DisplayName = "Demis Bellot TW" };

            var twitterTokens = new OAuthTokens {
                Provider = TwitterAuthConfig.Name,
                RequestToken = "JGz2CcwqgB1GR5e0EmGFxzyxGTw2rwEFFcC8a9o7g",
                RequestTokenSecret = "qkCdURJ2R10bMieVQZZad7iSwWkPYJmtBYzPoM9q0",
                UserId = "133371690876022785",
            };
            var authInfo = new Dictionary<string, string> {
                {"user_id", "133371690876022785"},
                {"screen_name", "demisbellot"},
            };

            var oAuthUserSession = GetSession();
            oAuthUserSession.OnAuthenticated(service, twitterTokens, authInfo);

            Assert.That(oAuthUserSession.UserAuthId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo("Demis Bellot TW"));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(1));
            var authProvider = authProviders[0];
            Assert.That(authProvider.UserAuthId, Is.EqualTo(userAuth.Id));
            Assert.That(authProvider.DisplayName, Is.EqualTo("Demis Bellot TW"));
            Assert.That(authProvider.FirstName, Is.Null);
            Assert.That(authProvider.LastName, Is.Null);
            Assert.That(authProvider.RequestToken, Is.EqualTo(twitterTokens.RequestToken));
            Assert.That(authProvider.RequestTokenSecret, Is.EqualTo(twitterTokens.RequestTokenSecret));

            Console.WriteLine(authProviders.Dump());
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:44,代码来源:OAuthUserSessionTests.cs

示例5: Does_persist_FacebookOAuth

        public void Does_persist_FacebookOAuth(IUserAuthRepository userAuthRepository)
        {
            ((IClearable)userAuthRepository).Clear();

            var mockService = new Mock<IServiceBase>();
            mockService.Expect(x => x.TryResolve<IUserAuthRepository>())
                .Returns(userAuthRepository);

            var serviceTokens = MockAuthHttpGateway.Tokens = new OAuthTokens {
                UserId = "623501766",
                DisplayName = "Demis Bellot FB",
                FirstName = "Demis",
                LastName = "Bellot",
                Email = "[email protected]",
            };

            var service = mockService.Object;
            var facebookTokens = new OAuthTokens {
                Provider = FacebookAuthConfig.Name,
                AccessTokenSecret = "AAADPaOoR848BAMkQIZCRIKnVWZAvcKWqo7Ibvec8ebV9vJrfZAz8qVupdu5EbjFzmMmbwUFDbcNDea9H6rOn5SVn8es7KYZD",
            };
            var authInfo = new Dictionary<string, string> { };

            var oAuthUserSession = GetSession();
            oAuthUserSession.OnAuthenticated(service, facebookTokens, authInfo);
            Assert.That(oAuthUserSession.FacebookUserId, Is.EqualTo(serviceTokens.UserId));

            Assert.That(oAuthUserSession.UserAuthId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
            Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokens.FirstName));
            Assert.That(userAuth.LastName, Is.EqualTo(serviceTokens.LastName));
            Assert.That(userAuth.Email, Is.EqualTo(serviceTokens.Email));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(1));
            var authProvider = authProviders[0];
            Assert.That(authProvider.UserAuthId, Is.EqualTo(userAuth.Id));
            Assert.That(authProvider.DisplayName, Is.EqualTo(serviceTokens.DisplayName));
            Assert.That(authProvider.FirstName, Is.EqualTo(serviceTokens.FirstName));
            Assert.That(authProvider.LastName, Is.EqualTo(serviceTokens.LastName));
            Assert.That(authProvider.Email, Is.EqualTo(serviceTokens.Email));
            Assert.That(authProvider.RequestToken, Is.Null);
            Assert.That(authProvider.RequestTokenSecret, Is.Null);
            Assert.That(authProvider.AccessToken, Is.Null);
            Assert.That(authProvider.AccessTokenSecret, Is.EqualTo(facebookTokens.AccessTokenSecret));

            Console.WriteLine(authProviders.Dump());
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:51,代码来源:OAuthUserSessionTests.cs

示例6: Does_merge_FacebookOAuth_TwitterOAuth

        public void Does_merge_FacebookOAuth_TwitterOAuth(IUserAuthRepository userAuthRepository)
        {
            ((IClearable)userAuthRepository).Clear();

            var mockService = new Mock<IServiceBase>();
            mockService.Expect(x => x.TryResolve<IUserAuthRepository>())
                .Returns(userAuthRepository);

            var service = mockService.Object;

            var serviceTokensFb = MockAuthHttpGateway.Tokens = new OAuthTokens {
                UserId = "623501766",
                DisplayName = "Demis Bellot FB",
                FirstName = "Demis",
                LastName = "Bellot",
                Email = "[email protected]",
            };

            var facebookTokens = new OAuthTokens {
                Provider = FacebookAuthConfig.Name,
                AccessTokenSecret = "AAADDDCCCoR848BAMkQIZCRIKnVWZAvcKWqo7Ibvec8ebV9vJrfZAz8qVupdu5EbjFzmMmbwUFDbcNDea9H6rOn5SVn8es7KYZD",
            };

            var oAuthUserSession = GetSession();
            oAuthUserSession.OnAuthenticated(service, facebookTokens, new Dictionary<string, string>());

            var serviceTokensTw = MockAuthHttpGateway.Tokens = new OAuthTokens { DisplayName = "Demis Bellot TW" };

            var twitterTokens = new OAuthTokens {
                Provider = TwitterAuthConfig.Name,
                RequestToken = "JGGZZ22CCqgB1GR5e0EmGFxzyxGTw2rwEFFcC8a9o7g",
                RequestTokenSecret = "qKKCCUUJ2R10bMieVQZZad7iSwWkPYJmtBYzPoM9q0",
                UserId = "133371690876022785",
            };
            var authInfo = new Dictionary<string, string> {
                {"user_id", "133371690876022785"},
                {"screen_name", "demisbellot"},
            };

            oAuthUserSession.OnAuthenticated(service, twitterTokens, authInfo);

            Assert.That(oAuthUserSession.TwitterUserId, Is.EqualTo(authInfo["user_id"]));
            Assert.That(oAuthUserSession.TwitterScreenName, Is.EqualTo(authInfo["screen_name"]));

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokensTw.DisplayName));
            Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokensFb.FirstName));
            Assert.That(userAuth.LastName, Is.EqualTo(serviceTokensFb.LastName));
            Assert.That(userAuth.Email, Is.EqualTo(serviceTokensFb.Email));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(2));

            Console.WriteLine(userAuth.Dump());
            Console.WriteLine(authProviders.Dump());
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:57,代码来源:OAuthUserSessionTests.cs

示例7: Does_merge_FacebookOAuth_TwitterOAuth

        public void Does_merge_FacebookOAuth_TwitterOAuth(IUserAuthRepository userAuthRepository)
        {
            InitTest(userAuthRepository);

            var serviceTokensFb = MockAuthHttpGateway.Tokens = facebookGatewayTokens;

            var oAuthUserSession = requestContext.ReloadSession();
            var facebookAuth = GetFacebookAuthProvider();
            facebookAuth.OnAuthenticated(service, oAuthUserSession, facebookAuthTokens, new Dictionary<string, string>());

            oAuthUserSession = requestContext.ReloadSession();

            var serviceTokensTw = MockAuthHttpGateway.Tokens = twitterGatewayTokens;
            var authInfo = new Dictionary<string, string> {
                {"user_id", "133371690876022785"},
                {"screen_name", "demisbellot"},
            };
            var twitterAuth = GetTwitterAuthProvider();
            twitterAuth.OnAuthenticated(service, oAuthUserSession, twitterAuthTokens, authInfo);

            oAuthUserSession = requestContext.ReloadSession();

            Assert.That(oAuthUserSession.TwitterUserId, Is.EqualTo(authInfo["user_id"]));
            Assert.That(oAuthUserSession.TwitterScreenName, Is.EqualTo(authInfo["screen_name"]));

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo(serviceTokensTw.DisplayName));
            Assert.That(userAuth.FirstName, Is.EqualTo(serviceTokensFb.FirstName));
            Assert.That(userAuth.LastName, Is.EqualTo(serviceTokensFb.LastName));
            Assert.That(userAuth.PrimaryEmail, Is.EqualTo(serviceTokensFb.Email));

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(2));

            Console.WriteLine(userAuth.Dump());
            Console.WriteLine(authProviders.Dump());
        }
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:38,代码来源:OAuthUserSessionTests.cs

示例8: Logging_in_pulls_all_AuthInfo_from_repo_after_logging_in_all_AuthProviders

        public void Logging_in_pulls_all_AuthInfo_from_repo_after_logging_in_all_AuthProviders(IUserAuthRepository userAuthRepository)
        {
            InitTest(userAuthRepository);

            var oAuthUserSession = requestContext.ReloadSession();

            //Facebook
            LoginWithFacebook(oAuthUserSession);

            //Twitter
            MockAuthHttpGateway.Tokens = twitterGatewayTokens;
            var authInfo = new Dictionary<string, string> {
                {"user_id", "133371690876022785"},
                {"screen_name", "demisbellot"},
            };
            var twitterAuth = GetTwitterAuthProvider();
            twitterAuth.OnAuthenticated(service, oAuthUserSession, twitterAuthTokens, authInfo);
            Console.WriteLine("UserId: " + oAuthUserSession.UserAuthId);

            //Register
            var registrationService = GetRegistrationService(userAuthRepository, oAuthUserSession, requestContext);

            var responseObj = registrationService.Post(registrationDto);
            Assert.That(responseObj as IHttpError, Is.Null, responseObj.ToString());

            Console.WriteLine("UserId: " + oAuthUserSession.UserAuthId);

            var credentialsAuth = GetCredentialsAuthConfig();
            var loginResponse = credentialsAuth.Authenticate(service, oAuthUserSession,
                new Auth
                {
                    provider = CredentialsAuthProvider.Name,
                    UserName = registrationDto.UserName,
                    Password = registrationDto.Password,
                });

            oAuthUserSession = requestContext.ReloadSession();

            Assert.That(oAuthUserSession.TwitterUserId, Is.EqualTo(authInfo["user_id"]));
            Assert.That(oAuthUserSession.TwitterScreenName, Is.EqualTo(authInfo["screen_name"]));

            var userAuth = userAuthRepository.GetUserAuth(oAuthUserSession.UserAuthId);
            Assert.That(userAuth.Id.ToString(CultureInfo.InvariantCulture), Is.EqualTo(oAuthUserSession.UserAuthId));
            Assert.That(userAuth.DisplayName, Is.EqualTo(registrationDto.DisplayName));
            Assert.That(userAuth.FirstName, Is.EqualTo(registrationDto.FirstName));
            Assert.That(userAuth.LastName, Is.EqualTo(registrationDto.LastName));
            Assert.That(userAuth.Email, Is.EqualTo(registrationDto.Email));

            Console.WriteLine(oAuthUserSession.Dump());
            Assert.That(oAuthUserSession.ProviderOAuthAccess.Count, Is.EqualTo(2));
            Assert.That(oAuthUserSession.IsAuthenticated, Is.True);

            var authProviders = userAuthRepository.GetUserOAuthProviders(oAuthUserSession.UserAuthId);
            Assert.That(authProviders.Count, Is.EqualTo(2));

            Console.WriteLine(userAuth.Dump());
            Console.WriteLine(authProviders.Dump());
        }
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:58,代码来源:OAuthUserSessionTests.cs


注:本文中的IUserAuthRepository.GetUserOAuthProviders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。