Exemple #1
0
        public MailMessage VerificationEmail(DeveloperAccountDTO account, AccountVerificationDTO verification)
        {
            MailMessage msg = new MailMessage();

            msg.To.Add(new MailAddress(account.Email, account.FirstName));
            msg.From       = shrtlnkMailAddress;
            msg.Subject    = "Please verify your email address - shrtlnk";
            msg.Body       = VerificationEmailBody(account.FirstName, verification.Id);
            msg.IsBodyHtml = true;
            return(msg);
        }
Exemple #2
0
 public bool SendVerificationEmail(DeveloperAccountDTO account, AccountVerificationDTO verification)
 {
     try
     {
         using (MailMessage msg = templates.VerificationEmail(account, verification))
         {
             SendMessage(msg);
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #3
0
        public DeveloperAccountDTO RegisterUser(RegisterAccountForm registration)
        {
            DeveloperAccountDTO account;

            try
            {
                string encryptedPassword = passwordService.HashPassword(registration.Password);

                account = new DeveloperAccountDTO()
                {
                    FirstName           = registration.FirstName,
                    LastName            = registration.LastName,
                    Email               = registration.Email,
                    AccountCreationDate = DateTime.Now,
                    Password            = encryptedPassword,
                    Role     = "Developer",
                    Verified = true
                };
            }
            catch
            {
                throw new PasswordEncryptionException();
            }

            try
            {
                accountsService.Create(account);
                AccountVerificationDTO av = verificationService.GenerateVerificationCode(account.Email);
                emailService.SendVerificationEmail(account, av);
            }
            catch (Exception e)
            {
                if (e.GetType() == typeof(MongoDB.Driver.MongoWriteException) &&
                    e.Message.Contains("duplicate key error"))
                {
                    throw new EmailAlreadyExistsError();
                }

                throw new DatabaseErrorException();
            }

            SetEmailToSession(account.Email);
            return(account);
        }