protected virtual async Task <ProcessConsentResult> ProcessConsentAsync() { var result = new ProcessConsentResult(); ConsentResponse grantedConsent; if (ConsentInput.UserDecision == "no") { grantedConsent = ConsentResponse.Denied; } else { grantedConsent = new ConsentResponse { RememberConsent = ConsentInput.RememberConsent, ScopesConsented = ConsentInput.GetAllowedScopeNames() }; } if (grantedConsent != null) { var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl); if (request == null) { return(result); } await _interaction.GrantConsentAsync(request, grantedConsent); result.RedirectUri = ReturnUrl; //TODO: ReturnUrlHash? } return(result); }
protected virtual async Task <ConsentModel.ProcessConsentResult> ProcessConsentAsync() { var result = new ConsentModel.ProcessConsentResult(); ConsentResponse grantedConsent; if (ConsentInput.UserDecision == "no") { grantedConsent = new ConsentResponse { Error = AuthorizationError.AccessDenied }; } else { if (!ConsentInput.IdentityScopes.IsNullOrEmpty() || !ConsentInput.ApiScopes.IsNullOrEmpty()) { grantedConsent = new ConsentResponse { RememberConsent = ConsentInput.RememberConsent, ScopesValuesConsented = ConsentInput.GetAllowedScopeNames() }; } else { throw new UserFriendlyException("You must pick at least one permission"); //TODO: How to handle this } } if (grantedConsent != null) { var request = await _interaction.GetAuthorizationContextAsync(ReturnUrl); if (request == null) { return(result); } await _interaction.GrantConsentAsync(request, grantedConsent); result.RedirectUri = ReturnUrl; //TODO: ReturnUrlHash? } return(result); }