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


C# User.ChangePassword方法代码示例

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


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

示例1: Context

 public void Context()
 {
     _user = UserBuilder.New
         .WithPassword(OldPassword)
         .Build();
     _user.ChangePassword(OldPassword, NewPassword);
 }
开发者ID:xhafan,项目名称:emailmaker,代码行数:7,代码来源:when_changing_password.cs

示例2: CanSaveAndLoadAggregate

        public void CanSaveAndLoadAggregate()
        {
            var store = CreateStore();

            var user = new User();
            user.Register("[email protected]", "password", Guid.NewGuid());
            user.ChangePassword("NewPassword");
            user.ChangeEmail("NewEmail");

            using (var session = OpenSession(store))
            {
                session.Save(user);
                session.SaveChanges();
            }

            using (var session = OpenSession(store))
            {
                var loadedUser = session.Get<User>(user.Id);

                Assert.That(loadedUser.Id, Is.EqualTo(user.Id));
                Assert.That(loadedUser.Email, Is.EqualTo(user.Email));
                Assert.That(loadedUser.Password, Is.EqualTo(user.Password));

            }
        }
开发者ID:RichieYang,项目名称:Composable.Monolithic,代码行数:25,代码来源:EventStoreSessionTests.cs

示例3: After_migrated_should_get_ordinal_events

        public void After_migrated_should_get_ordinal_events()
        {
            var user = new User();
            user.Register("[email protected]", "password", Guid.NewGuid());
            using (var session = OpenSession(CreateStore(withMigrations:false)))
            {
                session.Save(user);
                user.ChangeEmail($"[email protected]");
                user.ChangeEmail($"[email protected]");
                user.ChangeEmail($"[email protected]");
                session.SaveChanges();
            }

            using (var session = OpenSession(CreateStore()))
            {
                var reader = session as IEventStoreReader;
                var history = reader.GetHistory(user.Id);
                user = session.Get<User>(user.Id);
                user.ChangePassword("NewPassword");
                user.ChangePassword("NewPassword1");
                user.ChangePassword("NewPassword2");
                user.ChangePassword("NewPassword3");
                session.SaveChanges();

            }

            using (var session = OpenSession(CreateStore()))
            {
                var reader = session as IEventStoreReader;
      
                var history1 = reader.GetHistory(user.Id);
                var history2 = reader.GetHistory(user.Id);
                var history3 = reader.GetHistory(user.Id);

                history1.Count().Should().Be(history2.Count());
                history2.Count().Should().Be(history3.Count());
            }
        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:38,代码来源:MigratedSqlServerEventStoreSessionTests.cs

示例4: VersionIncreasesWithEachAppliedEvent

        public void VersionIncreasesWithEachAppliedEvent()
        {
            var user = new User();
            Assert.That(user.Version, Is.EqualTo(0));

            user.Register("email", "password", Guid.NewGuid());
            Assert.That(user.Version, Is.EqualTo(1));

            user.ChangeEmail("NewEmail");
            Assert.That(user.Version, Is.EqualTo(2));

            user.ChangePassword("NewPassword");
            Assert.That(user.Version, Is.EqualTo(3));

        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:15,代码来源:AggregateRootTests.cs

示例5: GetChangesReturnsEmptyListAfterAcceptChangesCalled

        public void GetChangesReturnsEmptyListAfterAcceptChangesCalled()
        {
            var user = new User();
            var userAseventStored = user as IEventStored;
            Assert.That(user.Version, Is.EqualTo(0));

            user.Register("email", "password", Guid.NewGuid());
            userAseventStored.AcceptChanges();
            Assert.That(userAseventStored.GetChanges(), Is.Empty);

            user.ChangeEmail("NewEmail");
            userAseventStored.AcceptChanges();
            Assert.That(userAseventStored.GetChanges(), Is.Empty);

            user.ChangePassword("NewPassword");
            userAseventStored.AcceptChanges();
            Assert.That(userAseventStored.GetChanges(), Is.Empty);
        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:18,代码来源:AggregateRootTests.cs

示例6: btnSearch_Click

 protected void btnSearch_Click(object sender, EventArgs e)
 {
     var oUser = new User();
     oUser.ChangePassword(lblUserName.Text, txtNewPassWord.Text);
     Label1.Visible = true;
 }
开发者ID:hungtien408,项目名称:web-quanaotreem,代码行数:6,代码来源:changepassword1.aspx.cs

示例7: btnChangePassword_Click

    protected void btnChangePassword_Click(object sender, EventArgs e)
    {
        try
        {
            var oUser = new User();
            var btnChangePassword = sender as RadButton;
            var row = btnChangePassword.Parent;

            var UserName = (row.FindControl("txtUserName") as RadTextBox).Text;
            var Password = (row.FindControl("txtPassword") as RadTextBox).Text;

            if (Membership.FindUsersByName(UserName).Count == 0)
                oUser.UserInsert(UserName, UserName, Password, "");
            else
                oUser.ChangePassword(UserName, Password);
        }
        catch (Exception ex)
        {
            lblError.Text = ex.Message;
        }
    }
开发者ID:hungtien408,项目名称:web-quanaotreem,代码行数:21,代码来源:customer.aspx.cs

示例8: SubmitButton_Click

				private void SubmitButton_Click(object sender, System.EventArgs e)
				{
					
					User user = null;
					try
					{
						if (m_securityProvider != null)
						{
							// We instantiate a User object, but skip the authentication. Here's why:
							// - Under AD authentication mode, current password will be verified by ChangePassword().
							// - Under RSA authentication mode, we can use a token (i.e. old password substitution) only
							//   once and if we perform authentication, we will not be able to create a new pin using the
							//   same token again because the RSA server will reject our request to create a pin.
							user = new User(m_usernameTextBox.Text, m_oldPasswordTextBox.Text, m_securityProvider.ApplicationName, m_securityProvider.Server, m_securityProvider.AuthenticationMode, false);
							
							if (! user.IsDefined)
							{
								// Don't proceed, account doesn't exist for user.
								m_container.UpdateMessageText("Operation aborted. No such account.", MessageType.Error);
								return;
							}
							else if (user.IsLockedOut)
							{
								// Don't proceed, user's account has been locked.
								m_container.UpdateMessageText("Operation aborted. Account is locked.", MessageType.Error);
								return;
							}
							else if (m_securityProvider.AuthenticationMode == AuthenticationMode.AD)
							{
								// Under AD authentication, the following restriction apply:
								if (! user.IsExternal)
								{
									// Don't proceed, only external user can change their password from here.
									m_container.UpdateMessageText("Operation aborted. Internal users cannot perform this task.", MessageType.Error);
									return;
								}
								else
								{
									// User's old and new password must be verified.
									if (user.Password != user.EncryptPassword(m_oldPasswordTextBox.Text))
									{
										// Don't proceed, user's failed to provide the correct current password.
										m_container.UpdateMessageText("Operation aborted. Old password verification failed.", MessageType.Error);
										return;
									}
									
									try
									{
										user.EncryptPassword(m_newPasswordTextBox.Text);
									}
									catch (Exception ex)
									{
										// Don't proceed, user's new password doesn't meeet strong password requirements.
										m_container.UpdateMessageText(ex.Message.Replace(Environment.NewLine, "<br />"), MessageType.Error);
										return;
									}
								}
							}
							
							// Go ahead and attempt to change the user password or create a new pin.
							if (user.ChangePassword(m_oldPasswordTextBox.Text, m_newPasswordTextBox.Text))
							{
								// Inform user about the success.
								if (m_securityProvider.AuthenticationMode == AuthenticationMode.AD)
								{
									m_container.UpdateMessageText("Your password has been changed!<br />You can now use your new password to login.", MessageType.Information);
								}
								else if (m_securityProvider.AuthenticationMode == AuthenticationMode.RSA)
								{
									this.Enabled = false;
									Page.Session.Remove(Login.NewPinVerify);
									m_container.UpdateMessageText("Your new pin has been created!<br />Please wait for the token to change before next login.", MessageType.Information);
								}
							}
							else
							{
								// This is highly unlikely because we've performed all checks before we actually attempted
								// to change the password or create a new pin.
								m_container.UpdateMessageText("Operation failed. Reason unknown.", MessageType.Error);
							}
						}
					}
					catch (Exception ex)
					{
						// Show the encountered exception to the user.
						m_container.UpdateMessageText(string.Format("ERROR: {0}", ex.Message), MessageType.Error);
						// Log encountered exception to security database if possible.
						if (user != null)
						{
							user.LogError("API -> Change Password Control -> Submit", ex.ToString());
						}
					}
					
				}
开发者ID:avs009,项目名称:gsf,代码行数:94,代码来源:ChangePassword.cs

示例9: A_nova_senha_nao_pode_ser_igual_a_anterior

 public void A_nova_senha_nao_pode_ser_igual_a_anterior()
 {
     var user = new User("André Baltieri", "[email protected]", "xpto0030");
     user.ChangePassword("andrebaltieri", "xpto0030", "xpto0030", "xpto0030");
 }
开发者ID:AndrewMak,项目名称:ngtodo,代码行数:5,代码来源:UserTests.cs

示例10: A_nova_senha_deve_ser_valida

 public void A_nova_senha_deve_ser_valida()
 {
     var user = new User("André Baltieri", "[email protected]", "xpto0030");
     user.ChangePassword("andrebaltieri", "xpto0030", "00", "00");
 }
开发者ID:AndrewMak,项目名称:ngtodo,代码行数:5,代码来源:UserTests.cs

示例11: A_confirmacao_de_senha_deve_ser_valida

 public void A_confirmacao_de_senha_deve_ser_valida()
 {
     var user = new User("André Baltieri", "[email protected]", "xpto0030");
     user.ChangePassword("andrebaltieri", "xpto0030", "wpt0328", "wpt0327");
 }
开发者ID:AndrewMak,项目名称:ngtodo,代码行数:5,代码来源:UserTests.cs


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