public async Task <IActionResult> UserCodeCapture(string userCode) { DeviceAuthorizationViewModel vm = await BuildViewModelAsync(userCode); if (vm == null) { return(View("Error")); } return(View("UserCodeConfirmation", vm)); }
public async Task <IActionResult> Index() { string userCodeParamName = _options.Value.UserInteraction.DeviceVerificationUserCodeParameter; string userCode = Request.Query[userCodeParamName]; if (string.IsNullOrWhiteSpace(userCode)) { return(View("UserCodeCapture")); } DeviceAuthorizationViewModel vm = await BuildViewModelAsync(userCode); if (vm == null) { return(View("Error")); } vm.ConfirmUserCode = true; return(View("UserCodeConfirmation", vm)); }
private DeviceAuthorizationViewModel CreateConsentViewModel(string userCode, DeviceAuthorizationInputModel model, DeviceFlowAuthorizationRequest request) { var vm = new DeviceAuthorizationViewModel { UserCode = userCode, Description = model?.Description, RememberConsent = model?.RememberConsent ?? true, ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty <string>(), ClientName = request.Client.ClientName ?? request.Client.ClientId, ClientUrl = request.Client.ClientUri, ClientLogoUrl = request.Client.LogoUri, AllowRememberConsent = request.Client.AllowRememberConsent }; vm.IdentityScopes = request.ValidatedResources.Resources.IdentityResources.Select(x => CreateScopeViewModel(x, vm.ScopesConsented.Contains(x.Name) || model == null)).ToArray(); var apiScopes = new List <ScopeViewModel>(); foreach (ParsedScopeValue parsedScope in request.ValidatedResources.ParsedScopes) { ApiScope apiScope = request.ValidatedResources.Resources.FindApiScope(parsedScope.ParsedName); if (apiScope != null) { ScopeViewModel scopeVm = CreateScopeViewModel(parsedScope, apiScope, vm.ScopesConsented.Contains(parsedScope.RawValue) || model == null); apiScopes.Add(scopeVm); } } if (ConsentOptions.EnableOfflineAccess && request.ValidatedResources.Resources.OfflineAccess) { apiScopes.Add(GetOfflineAccessScope(vm.ScopesConsented.Contains(IdentityServer4.IdentityServerConstants.StandardScopes.OfflineAccess) || model == null)); } vm.ApiScopes = apiScopes; return(vm); }