public UserPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService) : base(navigationService) { _pageDialogService = pageDialogService; _googleService = googleService; _facebookService = facebookService; _appleService = appleService; _multiFactorService = new MultiFactorService(this); Title = "User"; var user = _auth.CurrentUser; Update(user); Name = new ReactivePropertySlim <string>(user?.DisplayName); Email = new ReactivePropertySlim <string>(user?.Email); PhoneNumber = new ReactivePropertySlim <string>(user?.PhoneNumber); _isEnrolledMultiFactor.Value = user.MultiFactor.EnrolledFactors.Any(); UpdateNameCommand.Subscribe(UpdateName); UpdateEmailCommand.Subscribe(UpdateEmail); UpdatePhoneNumberCommand.Subscribe(UpdatePhoneNumber); SignOutCommand.Subscribe(SignOut); LinkOrUnlinkWithGoogleCommand.Subscribe(() => IsLinkedWithGoogle.Value ? UnlinkWithProvider("google.com") : LinkWithGoogle()); LinkOrUnlinkWithTwitterCommand.Subscribe(() => IsLinkedWithTwitter.Value ? UnlinkWithProvider("twitter.com") : LinkWithProvider("twitter.com")); LinkOrUnlinkWithFacebookCommand.Subscribe(() => IsLinkedWithFacebook.Value ? UnlinkWithProvider("facebook.com") : LinkWithFacebook()); LinkOrUnlinkWithGitHubCommand.Subscribe(() => IsLinkedWithGitHub.Value ? UnlinkWithProvider("github.com") : LinkWithProvider("github.com")); LinkOrUnlinkWithYahooCommand.Subscribe(() => IsLinkedWithYahoo.Value ? UnlinkWithProvider("yahoo.com") : LinkWithProvider("yahoo.com")); LinkOrUnlinkWithMicrosoftCommand.Subscribe(() => IsLinkedWithMicrosoft.Value ? UnlinkWithProvider("microsoft.com") : LinkWithProvider("microsoft.com")); LinkOrUnlinkWithAppleCommand.Subscribe(() => IsLinkedWithApple.Value ? UnlinkWithProvider("apple.com") : LinkWithApple()); EnrollOrUnenrollMultiFactorCommand.Subscribe(() => IsEnrolledMultiFactor.Value ? UnenrollMultiFactor() : EnrollMultiFactor()); DeleteCommand.Subscribe(Delete); }
public async Task <ActionResult <CommandResult> > Put(Guid id, [FromBody] string email) { var command = new UpdateEmailCommand(id, email); await commandBus.Run(command); await unitOfWork.Commit(); return(Ok(command.Result)); }
public void ShouldBeValid(string email) { var request = new UpdateEmailCommand { NewEmail = email }; var testResults = _validator.TestValidate(request); testResults.IsValid.Should().BeTrue(); }
public void ShouldNotBeValid_WhenEmailIsInvalid(string email) { var request = new UpdateEmailCommand { NewEmail = email }; var testResults = _validator.TestValidate(request); testResults.ShouldHaveValidationErrorFor(x => x.NewEmail); }
public void IsValid_ShouldBeFalse_WhenRequiredFieldsAreNotSet() { var command = new UpdateEmailCommand(); var validator = new UpdateEmailCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(false); }
public async Task <IActionResult> ChangeEmail([FromBody] UpdateEmailRequest request, CancellationToken cancellationToken) { var command = UpdateEmailCommand.FromRequest(_currentUserId, request); var result = await _mediator.Send(command, cancellationToken); return(result.IsSuccess ? Ok() : result.ReturnErrorResponse()); }
public async Task <ActionResult> Update(long id, UpdateEmailCommand command) { if (id != command.Id) { return(BadRequest()); } await Mediator.Send(command); return(NoContent()); }
public UserPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAuthService authService) : base(navigationService) { _pageDialogService = pageDialogService; _authService = authService; Title = "User"; _user.Value = CrossFirebaseAuth.Current.Instance.CurrentUser; Name = new ReactivePropertySlim <string>(_user.Value?.DisplayName); Email = new ReactivePropertySlim <string>(_user.Value?.Email); PhoneNumber = new ReactivePropertySlim <string>(_user.Value?.PhoneNumber); IsLinkedWithGoogle = _user.Where(user => user != null) .Select(user => user.ProviderData.FirstOrDefault(data => data.ProviderId == CrossFirebaseAuth.Current.GoogleAuthProvider.ProviderId) != null) .ToReadOnlyReactivePropertySlim(); IsLinkedWithTwitter = _user.Where(user => user != null) .Select(user => user.ProviderData.FirstOrDefault(data => data.ProviderId == CrossFirebaseAuth.Current.TwitterAuthProvider.ProviderId) != null) .ToReadOnlyReactivePropertySlim(); IsLinkedWithFacebook = _user.Where(user => user != null) .Select(user => user.ProviderData.FirstOrDefault(data => data.ProviderId == CrossFirebaseAuth.Current.FacebookAuthProvider.ProviderId) != null) .ToReadOnlyReactivePropertySlim(); IsLinkedWithGitHub = _user.Where(user => user != null) .Select(user => user.ProviderData.FirstOrDefault(data => data.ProviderId == CrossFirebaseAuth.Current.GitHubAuthProvider.ProviderId) != null) .ToReadOnlyReactivePropertySlim(); _user.Where(user => user != null) .Select(user => user.DisplayName) .DistinctUntilChanged() .Subscribe(name => Name.Value = name); _user.Where(user => user != null) .Select(user => user.Email) .DistinctUntilChanged() .Subscribe(email => Email.Value = email); _user.Where(user => user != null) .Select(user => user.PhoneNumber) .DistinctUntilChanged() .Subscribe(phoneNumber => PhoneNumber.Value = phoneNumber); UpdateNameCommand.Subscribe(UpdateName); UpdateEmailCommand.Subscribe(UpdateEmail); UpdatePhoneNumberCommand.Subscribe(UpdatePhoneNumber); SignOutCommand.Subscribe(SignOut); LinkOrUnlinkWithGoogleCommand.Subscribe(() => IsLinkedWithGoogle.Value ? UnlinkWithGoogle() : LinkWithGoogle()); LinkOrUnlinkWithTwitterCommand.Subscribe(() => IsLinkedWithTwitter.Value ? UnlinkWithTwitter() : LinkWithTwitter()); LinkOrUnlinkWithFacebookCommand.Subscribe(() => IsLinkedWithFacebook.Value ? UnlinkWithFacebook() : LinkWithFacebook()); LinkOrUnlinkWithGitHubCommand.Subscribe(() => IsLinkedWithGitHub.Value ? UnlinkWithGitHub() : LinkWithGitHub()); DeleteCommand.Subscribe(Delete); }
public async Task <IActionResult> UpdateEmail([FromBody] UpdateEmailCommand updateEmailCommand) { var message = await _mediator.Send(updateEmailCommand); if (message == "") { return(Ok("The password sent")); } return(BadRequest("User with the same email address didn`t found")); }
public async Task <IActionResult> UpdateEmailAsync([FromBody] UpdateEmailRequest model, CancellationToken token) { try { var command = new UpdateEmailCommand(model.UserId, model.Email); await _commandBus.DispatchAsync(command, token); return(Ok()); } catch (ArgumentException) { return(BadRequest()); } }
public async Task <IActionResult> UpdateEmail([FromBody] UpdateEmailCommand command) { var user = await _usermanager.FindByIdAsync(command.UserId.ToString()); var token = await _usermanager.GenerateChangeEmailTokenAsync(user, command.Email); var result = await _usermanager.ChangeEmailAsync(user, command.Email, token); if (!result.Succeeded) { return(BadRequest()); } return(Ok()); }
public ActionResult UpdateEmail(UpdateEmailCommand updateInformationCommand) { if (!ModelState.IsValid) { return(this.View()); } var context = new AppDbContext(); var customerToUpdate = context.Customers.Find(updateInformationCommand.CustomerId); customerToUpdate.Email = updateInformationCommand.Email; context.SaveChanges(); return(RedirectToAction("UpdateEmail")); }
public void Handle_GivenInvalidId_ThrowsException() { var command = new UpdateEmailCommand { Id = 99, Description = "Test Update Description", Subject = "Test Update Subject", Body = "Test Update Body" }; var handler = new UpdateEmailCommand.UpdateEmailCommandHandler(Context); Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public void IsValid_ShouldBeTrue_WhenRequiredFieldsAreSet() { var command = new UpdateEmailCommand { Id = 1, Description = "test Description", Subject = "test Subject", Body = "test Body" }; var validator = new UpdateEmailCommandValidator(Context); var result = validator.Validate(command); result.IsValid.ShouldBe(true); }
public async Task GivenValidUpdateEmailCommand_ReturnsSuccessCode() { var client = await _factory.GetAuthenticatedClientAsync(); var command = new UpdateEmailCommand { Id = 1, Description = "Test Description Update", Subject = "Test Subject Update", Body = "Test Body Update" }; var content = IntegrationTestHelper.GetRequestContent(command); var response = await client.PutAsync($"/api/Email/{command.Id}", content); response.EnsureSuccessStatusCode(); }
public async Task Handle_GivenValidId_ShouldUpdatePersistedEmail() { var command = new UpdateEmailCommand { Id = 1, Description = "Test Update Description", Subject = "Test Update Subject", Body = "Test Update Body" }; var handler = new UpdateEmailCommand.UpdateEmailCommandHandler(Context); await handler.Handle(command, CancellationToken.None); var entity = Context.Emails.Find(command.Id); entity.ShouldNotBeNull(); entity.Description.ShouldBe(command.Description); entity.Subject.ShouldBe(command.Subject); entity.Body.ShouldBe(command.Body); }
public async Task <BaseResponse> UpdateEmail(UpdateEmailCommand updateEmailCommand) { var result = await _mediator.Send(updateEmailCommand); return(result); }
public ActionResult UpdateEmail(UpdateEmailCommand updateEmailCommand) { return(this.ExecuteCommand(updateEmailCommand, () => this.RedirectToAction("UpdateEmail"))); }
public async Task <IActionResult> UpdateEmail(UpdateEmailCommand command) => await Handle(command.WithCallback("https://localhost:3000/security/email/confirmation"));