コード例 #1
0
        public void SaveValidationRequest(MailValidationRequest request)
        {
            Require.NotNull(request, nameof(request));

            var session = _sessionProvider.GetCurrentSession();
            session.Save(request);
        }
コード例 #2
0
        public void DeleteValidationToken(MailValidationRequest request)
        {
            Require.NotNull(request, nameof(request));

            var session = _sessionProvider.GetCurrentSession();
            session.Delete(request);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }