Пример #1
0
 public RequestPasswordResetHandler(
     IUnitOfWork unitOfWork,
     IPasswordResetTokenSenderService passwordResetTokenSenderService,
     IAlphanumericTokenGenerator alphanumericTokenGenerator)
 {
     _unitOfWork = unitOfWork;
     _passwordResetTokenSenderService = passwordResetTokenSenderService;
     _alphanumericTokenGenerator      = alphanumericTokenGenerator;
 }
        public void SendResetRequest(
            IPasswordResetTokenSenderService passwordResetTokenSender,
            IAlphanumericTokenGenerator tokenGenerator)
        {
            //disable previous reset tokens
            PasswordResetTokens?.ToList().ForEach(i => i.IsActive = false);

            var newResetToken =
                new PasswordResetToken()
            {
                ResetToken = tokenGenerator.GenerateAlphanumericToken(64),
                IsActive   = true
            };

            PasswordResetTokens.Add(newResetToken);

            passwordResetTokenSender.SendResetToken(
                Account.PrimaryEmail,
                newResetToken
                );
        }