public async Task <Unit> Handle(SendMailAccessRequestCommand request, CancellationToken cancellationToken)
        {
            var appInfo = await _applicationInfoRepository.Get();

            var rfaProfiles = request.RfaEmails;

            if (rfaProfiles == default || !rfaProfiles.Any())
            {
                throw new NoRfaFoundException();
            }

            //Send mail to the rfa account
            await _repository.SendMail(
                new Message(
                    "AccessRequestRfa",
                    rfaProfiles,
                    "Nouvelle demande d'accès",
                    appInfo.NameApp.Value, request.FirstName, request.LastName, request.Email, _emailConfig.RedirectUrlAddUser
                    ), appInfo
                );

            //Send mail to user account
            await _repository.SendMail(
                new Message(
                    "AccessRequestUser",
                    new List <string> {
                request.Email
            },
                    "Votre demande d'accès a été prise en compte."
                    ), appInfo
                );

            return(new Unit());
        }
Ejemplo n.º 2
0
        public ContactUsResult ContactUs(ContactUsResult contactUs)
        {
            if (contactUs.ContactUsForm == null)
            {
                throw new ArgumentNullException("No ContactUsForm send");
            }

            if (string.IsNullOrEmpty(contactUs.ContactUsForm.Email))
            {
                throw new ArgumentException("Empty Email", nameof(contactUs.ContactUsForm.Email));
            }

            if (string.IsNullOrEmpty(contactUs.ContactUsForm.Text))
            {
                throw new ArgumentException("Empty Text", nameof(contactUs.ContactUsForm.Text));
            }

            string admin = _penAndPaperConfiguration.Value.EmailSender;

            IList <string> to = new List <string>();

            to.Add(admin);
            to.Add(contactUs.ContactUsForm.Email);

            _emailSender.SendMail(to, "Contact Us", "New Request with content: " + contactUs.ContactUsForm.Text);

            return(contactUs);
        }
Ejemplo n.º 3
0
 public LogInData GenerateUserLoginData(User user, IEmailSenderService emailSender)
 {
     string userLogin = this.GenerateLogin(user), userPassword = this.GeneratePassword(), salt = this.CreateSalt();
     string message = string.Format(Constants.EmailMessage + "\nЛогін: " + userLogin + "\nПароль: " + userPassword);
     emailSender.SendMail(user.Email, message);
     return new LogInData
         {
             Login = userLogin,
             PasswordSalt = salt,
             PasswordHash = this.CreateHashPassword(userPassword, salt)
         };
 }