public async Task <Unit> Handle(ChangePasswordCommand request, CancellationToken cancellationToken) { if (!await _passwordManager.IsPasswordValid(request.UserId, request.OldPassword)) { throw new UnauthorizedException("Unauthorized", $"User with id: {request.UserId} has been unauthorized"); } if (!await _passwordManager.UpdatePassword(request.UserId, request.OldPassword, request.OldPassword)) { throw new UnauthorizedException("Unauthorized", $"User with id: {request.UserId} has been unauthorized"); } return(Unit.Value); }
public void Confirm() { //Call Notes Dependency and add to the Collection of Notes, along to the database try { if (string.IsNullOrWhiteSpace(Description)) { throw new ArgumentNullException("Description cannot be empty"); } if (string.IsNullOrWhiteSpace(Password)) { throw new ArgumentNullException("Password cannot be empty"); } if (!string.IsNullOrWhiteSpace(Constants.Passwords_ID)) { var password = _passwordManager.Get_PasswordByID <Passwords>(Constants.Passwords_ID); if (password != null) { password.Password = Password; password.Description = Description; _passwordManager.UpdatePassword(password); MessagingCenter.Send <PasswordCreatorViewModel, Passwords>(this, _UpdatePassword, password); } else { var obj = new Passwords(); obj.Contact_ID_Ref = Constants.InMemory_ContactID; obj.Password_ID = _passwordManager.Get_NewPasswordID(); obj.Description = Description; obj.Password = Password; obj.Sys_Creation = DateTime.Now; obj.Sys_Transaction = DateTime.Now; _passwordManager.AddPassword(obj); MessagingCenter.Send <PasswordCreatorViewModel, Passwords>(this, _AddPassword, obj); } } else { var obj = new Passwords(); obj.Contact_ID_Ref = Constants.InMemory_ContactID; obj.Password_ID = _passwordManager.Get_NewPasswordID(); obj.Description = Description; obj.Password = Password; obj.Sys_Creation = DateTime.Now; obj.Sys_Transaction = DateTime.Now; _passwordManager.AddPassword(obj); MessagingCenter.Send <PasswordCreatorViewModel, Passwords>(this, _AddPassword, obj); } //Pop to previous page if (navigation != null) { navigation.GoBackAsync(true); } } catch (Exception ex) { string eMessage = string.Empty; string eStackTrace = string.Empty; if (ex.InnerException != null) { eMessage = ex.InnerException.Message; eStackTrace = ex.InnerException.StackTrace; } else { eMessage = ex.Message; eStackTrace = ex.StackTrace; } var mEx = new Exceptions(logging, eMessage, eStackTrace); if (mEx != null) { mEx.HandleException(mEx, logging); } //Output a dialogue here if (dialogue != null && mEx != null) { dialogue.ShowAlert("mmm...Something went wrong", mEx.Message); } } }