public void SaveValidationRequest(MailValidationRequest request) { Require.NotNull(request, nameof(request)); var session = _sessionProvider.GetCurrentSession(); session.Save(request); }
public void DeleteValidationToken(MailValidationRequest request) { Require.NotNull(request, nameof(request)); var session = _sessionProvider.GetCurrentSession(); session.Delete(request); }
public void SetupEmailConfirmation(int userId) { Require.Positive(userId, nameof(userId)); var token = TokenGenerator.GenerateToken(); var @event = new MailValidationRequest(userId, token); _eventBus.PublishEvent("MailValidationRequest", "validate_mail", @event); }
public void ConfirmationServiceConfirmsProfile() { var mailValidationRq = new MailValidationRequest(42, "thisistoken"); _validationRequesRepoStub.Setup(rep => rep.GetMailValidationRequest(It.IsAny<string>())) .Returns(mailValidationRq); var testAccMock = new Mock<Account>(); testAccMock.Setup(acc => acc.UserId).Returns(42); testAccMock.Setup(acc => acc.ConfirmationStatus).Returns(ConfirmationStatus.Unconfirmed); _userRepoStub.Setup(rep => rep.GetAccount(mailValidationRq.UserId)).Returns(testAccMock.Object); //act _confirmationService.ConfirmProfile(mailValidationRq.UserId); //assert testAccMock.VerifySet(mock => mock.ConfirmationStatus = ConfirmationStatus.FullyConfirmed); }
public void SetupEmailConfirmation(int userId) { Require.Positive(userId, nameof(userId)); var token = TokenGenerator.GenerateToken(); var request = new MailValidationRequest(userId, token); _validationRequestsRepository.SaveValidationRequest(request); var confirmationLink = new Uri( _confirmationSettings.FrontendMailConfirmationUri, token); _mailer.SendConfirmationMail(confirmationLink.AbsoluteUri, _userRepository.GetAccount(userId).Email); }