Esempio n. 1
0
        public static async Task <bool> SignUpAsync(HttpContextBase context, string tenant, Registration model, RemoteUser user)
        {
            if (model.Password != model.ConfirmPassword)
            {
                throw new PasswordConfirmException(I18N.PasswordsDoNotMatch);
            }

            if (model.Email != model.ConfirmEmail)
            {
                throw new PasswordConfirmException(I18N.EmailsDoNotMatch);
            }

            model.Browser   = user.Browser;
            model.IpAddress = user.IpAddress;

            var registration = model.Adapt <DTO.Registration>();

            registration.Password = PasswordManager.GetHashedPassword(model.Email, model.Password);

            string registrationId =
                (await Registrations.RegisterAsync(tenant, registration).ConfigureAwait(false)).ToString();

            if (string.IsNullOrWhiteSpace(registrationId))
            {
                return(false);
            }

            var email = new SignUpEmail(context, registration, registrationId);
            await email.SendAsync(tenant).ConfigureAwait(false);

            return(true);
        }
Esempio n. 2
0
        public async Task <ActionResult> PostAsync(Registration model)
        {
            if (model.Password != model.ConfirmPassword)
            {
                throw new PasswordConfirmException("Passwords do not match.");
            }

            if (model.Email != model.ConfirmEmail)
            {
                throw new PasswordConfirmException("Passwords do not match.");
            }

            model.Browser   = this.RemoteUser.Browser;
            model.IpAddress = this.RemoteUser.IpAddress;

            Mapper.CreateMap <Registration, DTO.Registration>();
            DTO.Registration registration   = Mapper.Map <DTO.Registration>(model);
            string           registrationId = DAL.Registration.Register(registration).ToString();

            if (string.IsNullOrWhiteSpace(registrationId))
            {
                return(Json(false));
            }

            SignUpEmail email = new SignUpEmail(registration, registrationId);
            await email.SendAsync();

            return(Json(true));
        }
Esempio n. 3
0
        public static async Task <bool> SignUp(Registration model, RemoteUser user)
        {
            if (model.Password != model.ConfirmPassword)
            {
                throw new PasswordConfirmException("Passwords do not match.");
            }

            if (model.Email != model.ConfirmEmail)
            {
                throw new PasswordConfirmException("Emails do not match.");
            }

            model.Browser   = user.Browser;
            model.IpAddress = user.IpAddress;

            var registration = model.Adapt <DTO.Registration>();

            registration.Password = PasswordManager.GetHashedPassword(model.Password);

            string registrationId = Registrations.Register(registration).ToString();

            if (string.IsNullOrWhiteSpace(registrationId))
            {
                return(false);
            }

            var email = new SignUpEmail(registration, registrationId);
            await email.SendAsync();

            return(true);
        }