Ejemplo n.º 1
0
        public async Task Register(string activateAccountLinkFormatted, UserRegisterModel model)
        {
            var duplicateEmail = Entities.Users.FirstOrDefault(u => u.Email == model.Email);
            if (duplicateEmail != null)
            {
                throw new ArgumentException(Strings.DuplicateEmail);
            }

            var hash = Security.HashSHA1(model.Password);

            var user = new User
            {
                Name = model.Name,
                Email = model.Email,
                CompanyName = model.CompanyName,
                PasswordHash = hash,
                EmailConfirmed = false,
                UID = Guid.NewGuid(),
                FirstLogin = false
            };

            Entities.Users.Add(user);
            await Entities.SaveChangesAsync();


            MailChimpHelper.AddEmail(model.Email);

            var data = new Dictionary<string, string>();
            data.Add("link", string.Format(activateAccountLinkFormatted, user.UID));

            var sender = new EmailSender();
            sender.Send(Templates.AccountActivation, model.Email, data);
        }
Ejemplo n.º 2
0
        public void ForgotPassword(string resetLinkFormatted, ForgotPasswordModel model)
        {
            var user = Entities.Users.FirstOrDefault(u => u.Email == model.Email);
            if (user == null)
            {
                throw new ArgumentException(Strings.EmailNotExist);
            }

            var data = new Dictionary<string, string>();
            data.Add("link", string.Format(resetLinkFormatted, user.UID));

            var sender = new EmailSender();
            sender.Send(Templates.ResetPassword, user.Email, data);
        }