コード例 #1
0
ファイル: SignUpModel.cs プロジェクト: frapid/frapid
        public static async Task<bool> SignUpAsync(HttpContextBase context, string tenant, 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 =
                (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;
        }
コード例 #2
0
ファイル: SignupController.cs プロジェクト: frapid/frapid
 public async Task<ActionResult> PostAsync(Registration model)
 {
     bool result = await SignUpModel.SignUpAsync(this.HttpContext, this.Tenant, model, this.RemoteUser).ConfigureAwait(true);
     return this.Ok(result);
 }