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


C# IUserAuthRepository.GetUserAuthByUserName方法代码示例

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


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

示例1: Can_login_with_user_created_CreateUserAuth

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

            var registrationService = GetRegistrationService(userAuthRepository);

            var responseObj = registrationService.Post(registrationDto);

            var httpResult = responseObj as IHttpResult;
            if (httpResult != null)
            {
                Assert.Fail("HttpResult found: " + httpResult.Dump());
            }

            var response = (RegistrationResponse)responseObj;
            Assert.That(response.UserId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(response.UserId);
            AssertEqual(userAuth, registrationDto);

            userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.UserName);
            AssertEqual(userAuth, registrationDto);

            userAuth = userAuthRepository.GetUserAuthByUserName(registrationDto.Email);
            AssertEqual(userAuth, registrationDto);

            UserAuth userId;
            var success = userAuthRepository.TryAuthenticate(registrationDto.UserName, registrationDto.Password, out userId);
            Assert.That(success, Is.True);
            Assert.That(userId, Is.Not.Null);

            success = userAuthRepository.TryAuthenticate(registrationDto.Email, registrationDto.Password, out userId);
            Assert.That(success, Is.True);
            Assert.That(userId, Is.Not.Null);

            success = userAuthRepository.TryAuthenticate(registrationDto.UserName, "Bad Password", out userId);
            Assert.That(success, Is.False);
            Assert.That(userId, Is.Null);
        }
开发者ID:nstjelja,项目名称:ServiceStack,代码行数:39,代码来源:OAuthUserSessionTests.cs

示例2: 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:nstjelja,项目名称:ServiceStack,代码行数:17,代码来源:OAuthUserSessionTests.cs

示例3: Can_DeleteUserAuth

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

            var oAuthUserSession = requestContext.ReloadSession();
            oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);

            var userAuth = userAuthRepository.GetUserAuthByUserName(RegisterDto.UserName);
            Assert.That(userAuth, Is.Not.Null);

            userAuthRepository.DeleteUserAuth(userAuth.Id.ToString());
            userAuth = userAuthRepository.GetUserAuthByUserName(RegisterDto.UserName);
            Assert.That(userAuth, Is.Null);
        }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:14,代码来源:OAuthUserSessionTests.cs

示例4: Registering_twice_in_same_session_updates_registration

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

            var oAuthUserSession = requestContext.ReloadSession();

            oAuthUserSession = RegisterAndLogin(userAuthRepository, oAuthUserSession);

            var userName1 = RegisterDto.UserName;
            var userName2 = "UserName2";
            RegisterDto.UserName = userName2;

            Register(userAuthRepository, oAuthUserSession, RegisterDto);

            var userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
            var userAuth2 = userAuthRepository.GetUserAuthByUserName(userName2);

            Assert.That(userAuth1, Is.Null);
            Assert.That(userAuth2, Is.Not.Null);
        }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:20,代码来源:OAuthUserSessionTests.cs

示例5: Registering_twice_creates_two_registrations

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

            var oAuthUserSession = requestContext.ReloadSession();

            RegisterAndLogin(userAuthRepository, oAuthUserSession);

            requestContext.RemoveSession();

            var userName1 = RegisterDto.UserName;
            var userName2 = "UserName2";
            RegisterDto.UserName = userName2;
            RegisterDto.Email = "[email protected]";

            var userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
            Assert.That(userAuth1, Is.Not.Null);

            Register(userAuthRepository, oAuthUserSession, RegisterDto);

            userAuth1 = userAuthRepository.GetUserAuthByUserName(userName1);
            var userAuth2 = userAuthRepository.GetUserAuthByUserName(userName2);

            Assert.That(userAuth1, Is.Not.Null);
            Assert.That(userAuth2, Is.Not.Null);
        }
开发者ID:jrmitch120,项目名称:ServiceStack,代码行数:26,代码来源:OAuthUserSessionTests.cs

示例6: Can_login_with_user_created_CreateUserAuth

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

            var request = new Registration {
                UserName = "UserName",
                Password = "[email protected]",
                Email = "[email protected]",
                DisplayName = "DisplayName",
                FirstName = "FirstName",
                LastName = "LastName",
            };
            var loginService = new RegistrationService {
                UserAuthRepo = userAuthRepository,
                RegistrationValidator = new RegistrationValidator { UserAuthRepo = RegistrationServiceTests.GetStubRepo() },
            };

            var responseObj = loginService.Post(request);

            var httpResult = responseObj as IHttpResult;
            if (httpResult != null)
            {
                Assert.Fail("HttpResult found: " + httpResult.Dump());
            }

            var response = (RegistrationResponse)responseObj;
            Assert.That(response.UserId, Is.Not.Null);

            var userAuth = userAuthRepository.GetUserAuth(response.UserId);
            AssertEqual(userAuth, request);

            userAuth = userAuthRepository.GetUserAuthByUserName(request.UserName);
            AssertEqual(userAuth, request);

            userAuth = userAuthRepository.GetUserAuthByUserName(request.Email);
            AssertEqual(userAuth, request);

            string userId;
            var success = userAuthRepository.TryAuthenticate(request.UserName, request.Password, out userId);
            Assert.That(success, Is.True);
            Assert.That(userId, Is.Not.Null);

            success = userAuthRepository.TryAuthenticate(request.Email, request.Password, out userId);
            Assert.That(success, Is.True);
            Assert.That(userId, Is.Not.Null);

            success = userAuthRepository.TryAuthenticate(request.UserName, "Bad Password", out userId);
            Assert.That(success, Is.False);
            Assert.That(userId, Is.Null);
        }
开发者ID:austinvernsonger,项目名称:ServiceStack,代码行数:50,代码来源:OAuthUserSessionTests.cs

示例7: SeedUsers

        private static void SeedUsers(IUserAuthRepository users)
        {
            //check to see if user exists
            if (users.GetUserAuthByUserName("admin.user") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Admin User",
                        Email = "[email protected]",
                        UserName = "admin.user",
                        FirstName = "Admin",
                        LastName = "User",
                        PasswordHash = hash,
                        Salt = salt,
                        Roles = new List<string> {RoleNames.Admin},
                        Permissions = new List<string> {"God"}
                    }, pwd);
            }

            //check to see if user exists
            if (users.GetUserAuthByUserName("joe.budget") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Joe BudgetHolder",
                        Email = "[email protected]",
                        UserName = "joe.budget",
                        FirstName = "Joe",
                        LastName = "BudgetHolder",
                        PasswordHash = hash,
                        Salt = salt,
                        Roles = new List<string> {"BudgetUser"},
                        Permissions = new List<string> {"GiveAward"}
                    }, pwd);
            }

            //check to see if user exists
            if (users.GetUserAuthByUserName("jane.employee") == null)
            {
                //create user
                const string pwd = "password";
                string hash, salt;
                new SaltedHash().GetHashAndSaltString(pwd, out hash, out salt);
                users.CreateUserAuth(new UserAuth
                    {
                        Id = 1,
                        DisplayName = "Jane Employee",
                        Email = "[email protected]",
                        UserName = "jane.employee",
                        FirstName = "Jane",
                        LastName = "Employee",
                        PasswordHash = hash,
                        Salt = salt,
                    }, pwd);
            }
        }
开发者ID:arron-green,项目名称:ServiceStack.Example,代码行数:66,代码来源:AppHost.cs


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