public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl      = returnUrl ?? Url.Content("~/");
            ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList();
            if (ModelState.IsValid)
            {
                var user = new AtomHealthUser {
                    UserName = Input.Email, Email = Input.Email, FirstName = Input.FirstName, MiddleName = Input.MiddleName, LastName = Input.LastName
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code));
                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { area = "Identity", userId = user.Id, code = code, returnUrl = returnUrl },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Welcome to Atom Health. Thanks for Signing up!",
                                                      $"Hi {user.FirstName}," +
                                                      "<br/>" +
                                                      $"We are excited to see you sign up into Atom Health.In today's times when technology evolves everyday, a healthcare provider's responsibility extends way beyond providing care. Collaborative care between different specialists is the norm and access to relevant health information is critical to diagnosis and management. At Atom Health, we collect verified vital health information and store it in a secure encrypted digital health ID or ATOM of each patient." +
                                                      "<br/>" +
                                                      $"{user.FirstName}, your vital healthcare information stored under your unique digital health ID. Owned by you, verified by your family physician and you choose who views it. Sign up with us, create your profile and our software generates a unique digital ID, specific to you. All your vital health information- including your medical conditions, medications, allergies, past medical history, family history, genetic history, is stored securely in this unique digital healthID assigned to you, much like a passport carrying your travel history. You have the view-only access key on you at all times and can share that with another healthcare provider, whether you are doing a virtual consult on telemedicine platform or you are in a walk-in clinic. What's more? You can add family members or dependents and ensure their well-being too." +
                                                      "<br/>" +
                                                      $"Lastly, thanks again for trusting our company with your healthcare information. Stay safe {user.FirstName}!" +
                                                      "<br/>" +
                                                      "<br/>" +
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>." +
                                                      "<br/>" +
                                                      "<br/>" +
                                                      $"ATOM HEALTH TEAM");

                    if (_userManager.Options.SignIn.RequireConfirmedAccount)
                    {
                        return(RedirectToPage("RegisterConfirmation", new { email = Input.Email, returnUrl = returnUrl }));
                    }
                    else
                    {
                        await _signInManager.SignInAsync(user, isPersistent : false);

                        return(LocalRedirect(returnUrl));
                    }
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
        private async Task LoadAsync(AtomHealthUser user)
        {
            var userName = await _userManager.GetUserNameAsync(user);

            var phoneNumber = await _userManager.GetPhoneNumberAsync(user);

            Username = userName;

            Input = new InputModel
            {
                PhoneNumber = phoneNumber
            };
        }
        private async Task LoadAsync(AtomHealthUser user)
        {
            var email = await _userManager.GetEmailAsync(user);

            Email = email;

            Input = new InputModel
            {
                NewEmail = email,
            };

            IsEmailConfirmed = await _userManager.IsEmailConfirmedAsync(user);
        }
Exemplo n.º 4
0
        private async Task LoadSharedKeyAndQrCodeUriAsync(AtomHealthUser user)
        {
            // Load the authenticator key & QR code URI to display on the form
            var unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);

            if (string.IsNullOrEmpty(unformattedKey))
            {
                await _userManager.ResetAuthenticatorKeyAsync(user);

                unformattedKey = await _userManager.GetAuthenticatorKeyAsync(user);
            }

            SharedKey = FormatKey(unformattedKey);

            var email = await _userManager.GetEmailAsync(user);

            AuthenticatorUri = GenerateQrCodeUri(email, unformattedKey);
        }