コード例 #1
0
        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.EnableLocalLogin,

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

            return(vm);
        }
コード例 #2
0
        public async Task <IActionResult> Index(string returnUrl)
        {
            RecoverViewModel vm = await this.CreateViewModelAsync(returnUrl);

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

                return(this.Redirect(Url.Action("Index", "Error")));
            }

            return(this.View(vm));
        }