public IActionResult PasswordEdit([FromBody] PasswordEdit from) { if (!ModelState.IsValid) { return(RenderJsonSuccessResult(false, new { Message = ModelState.FirstErrorMessage() })); } if (!_accountService.CheckPassword(FullAccount.UserName, from.OldPassword)) { return(RenderJsonSuccessResult(false, new { Message = "旧密码输入错误" })); } try { _accountService.ChangePassword(FullAccount.Id, from.NewPassword); return(RenderJsonSuccessResult(true, new { Message = "修改成功" })); } catch (System.Exception ex) { LogUtility.Account.Error(ex.Message, ex); return(RenderJsonSuccessResult(false, new { Message = "修改密码失败" })); } }
public async Task <ActionResponse> UpdatePassword([FromBody] PasswordEdit passwordRequest) { string userId = authenticationCurrentContext.CurrentUser; Mdls.User user = await userRepository.Get(userId); if (user != null) { #region Verify Password Match string originalPassword = decryptionProvider.Decrypt(user.Password, user.EncryptionKey); bool verified = passwordRequest.CurrentPassword == originalPassword; #endregion if (verified) { string encryptedPassword = encryptionProvider.Encrypt(passwordRequest.Password); string encryptionKey = encryptionProvider.EncryiptionKey; bool updated = await userRepository.UpdatePassword(userId, encryptedPassword, encryptionKey); return(new ActionResponse { State = updated }); } } return(new ActionResponse { State = false }); }
public override bool ValidateChildren() { if (string.IsNullOrWhiteSpace(ServerNameEdit.Text)) { Resources.ServerNameCannotBeEmptyOrWhitesp.ShowError(); ServerNameEdit.Focus(); return(false); } if (UserNameEdit.Enabled && string.IsNullOrWhiteSpace(UserNameEdit.Text)) { Resources.UserNameCannotBeEmptyOrWhitespace.ShowError(); UserNameEdit.Focus(); return(false); } if (PasswordEdit.Enabled && string.IsNullOrWhiteSpace(PasswordEdit.Text)) { Resources.PasswordCannotBeEmptyOrWhitespace.ShowError(); PasswordEdit.Focus(); return(false); } if (DatabaseNameEdit.Enabled && string.IsNullOrWhiteSpace(DatabaseNameEdit.Text)) { Resources.DatabaseNameCannotBeEmptyOrWhitespace.ShowError(); DatabaseNameEdit.Focus(); return(false); } if (DatabaseFileEdit.Enabled && string.IsNullOrWhiteSpace(DatabaseFileEdit.Text)) { Resources.SelectDatabaseFile.ShowError(); DatabaseFileBtn.Focus(); return(false); } if (DatabaseLogicalNameEdit.Enabled && string.IsNullOrWhiteSpace(DatabaseLogicalNameEdit.Text)) { Resources.DatabaseNameCannotBeEmptyOrWhitespace.ShowError(); DatabaseLogicalNameEdit.Focus(); return(false); } return(true); }
public CreateDatabaseWindow(DBConnectData dbConnectData) { InitializeComponent(); enlargementStoryboard = (Storyboard)Resources["EnlargementStoryBoard"]; enlargementAnimation = (DoubleAnimation)enlargementStoryboard.Children[0]; this.dbConnectData = dbConnectData; DBFormatEdit.ItemsSource = EnumTitlesKeeper <DBFormat> .GetItemsList <EnumItem>(); DBFormatEdit.SetBinding(ListBoxEdit.EditValueProperty, new Binding("DBFormat") { Source = dbConnectData, Mode = BindingMode.TwoWay }); SqlServerEdit.SetBinding(TextEdit.TextProperty, new Binding("Server") { Source = dbConnectData, Mode = BindingMode.TwoWay }); SqlDatabaseEdit.SetBinding(TextEdit.TextProperty, new Binding("SqlDBName") { Source = dbConnectData }); MdbDatabaseEdit.SetBinding(TextEdit.TextProperty, new Binding("MdbPath") { Source = dbConnectData }); LoginEdit.SetBinding(TextEdit.TextProperty, new Binding("Login") { Source = dbConnectData, Mode = BindingMode.TwoWay }); PasswordEdit.SetBinding(TextEdit.TextProperty, new Binding("Password") { Source = dbConnectData, Mode = BindingMode.TwoWay }); AuthenticationTypeEdit.ItemsSource = EnumTitlesKeeper <SqlAuthenticationType> .GetItemsList <EnumItem>(); AuthenticationTypeEdit.SetBinding(ListBoxEdit.EditValueProperty, new Binding("SqlAuthenticationType") { Source = dbConnectData, Mode = BindingMode.TwoWay }); }
public LoginWindow() { InitializeComponent(); PasswordEdit.Focus(); }