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); }
public bool SendVerificationEmail(DeveloperAccountDTO account, AccountVerificationDTO verification) { try { using (MailMessage msg = templates.VerificationEmail(account, verification)) { SendMessage(msg); } return(true); } catch (Exception e) { return(false); } }
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); }