internal async Task <RecoverViewModel> CreateViewModelAsync(
            RecoverInputModel inputModel,
            UserAccount userAccount = null)
        {
            AuthorizationRequest context = await this._interaction
                                           .GetAuthorizationContextAsync(inputModel.ReturnUrl);

            if (context == null)
            {
                return(null);
            }

            Client client = await this._clientService
                            .FindEnabledClientByIdAsync(context.ClientId);

            IEnumerable <ExternalProvider> providers =
                await this._clientService.GetEnabledProvidersAsync(client);

            RecoverViewModel vm = new RecoverViewModel(inputModel)
            {
                EnableAccountRegistration =
                    this._applicationOptions.EnableAccountRegistration,

                EnableLocalLogin = (client != null ?
                                    client.EnableLocalLogin : false) &&
                                   this._applicationOptions.EnableAccountLogin,

                LoginHint             = context.LoginHint,
                ExternalProviders     = providers.ToArray(),
                ExternalProviderHints = userAccount?.Accounts?
                                        .Select(c => c.Provider)
            };

            return(vm);
        }
        public async Task <IActionResult> Index(string returnUrl)
        {
            RecoverViewModel vm = await this.CreateViewModelAsync(returnUrl);

            if (vm == null)
            {
                this._logger.LogWarning(ErrorMessages.RecoveryNoReturnUrl);

                return(this.RedirectToAction("Index", "Error"));
            }

            return(this.View(vm));
        }