2021-08-13 17:03:23 +05:30
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Identity.API.Models.AccountViewModels
|
2016-11-24 15:31:33 +01:00
|
|
|
|
{
|
2020-12-16 12:13:14 +01:00
|
|
|
|
public record ConsentViewModel : ConsentInputModel
|
2016-11-24 15:31:33 +01:00
|
|
|
|
{
|
2021-08-13 17:03:23 +05:30
|
|
|
|
public ConsentViewModel(ConsentInputModel model, string returnUrl, AuthorizationRequest request, IdentityServer4.Models.Client client, Resources resources)
|
2016-11-24 15:31:33 +01:00
|
|
|
|
{
|
|
|
|
|
RememberConsent = model?.RememberConsent ?? true;
|
|
|
|
|
ScopesConsented = model?.ScopesConsented ?? Enumerable.Empty<string>();
|
|
|
|
|
|
|
|
|
|
ReturnUrl = returnUrl;
|
|
|
|
|
|
|
|
|
|
ClientName = client.ClientName;
|
|
|
|
|
ClientUrl = client.ClientUri;
|
|
|
|
|
ClientLogoUrl = client.LogoUri;
|
|
|
|
|
AllowRememberConsent = client.AllowRememberConsent;
|
|
|
|
|
|
2017-04-05 09:18:14 -03:00
|
|
|
|
IdentityScopes = resources.IdentityResources.Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray();
|
|
|
|
|
ResourceScopes = resources.ApiResources.SelectMany(x => x.Scopes).Select(x => new ScopeViewModel(x, ScopesConsented.Contains(x.Name) || model == null)).ToArray();
|
2016-11-24 15:31:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 12:13:14 +01:00
|
|
|
|
public string ClientName { get; init; }
|
|
|
|
|
public string ClientUrl { get; init; }
|
|
|
|
|
public string ClientLogoUrl { get; init; }
|
|
|
|
|
public bool AllowRememberConsent { get; init; }
|
2016-11-24 15:31:33 +01:00
|
|
|
|
|
2020-12-16 12:13:14 +01:00
|
|
|
|
public IEnumerable<ScopeViewModel> IdentityScopes { get; init; }
|
|
|
|
|
public IEnumerable<ScopeViewModel> ResourceScopes { get; init; }
|
2016-11-24 15:31:33 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 12:13:14 +01:00
|
|
|
|
public record ScopeViewModel
|
2016-11-24 15:31:33 +01:00
|
|
|
|
{
|
|
|
|
|
public ScopeViewModel(Scope scope, bool check)
|
|
|
|
|
{
|
|
|
|
|
Name = scope.Name;
|
|
|
|
|
DisplayName = scope.DisplayName;
|
|
|
|
|
Description = scope.Description;
|
|
|
|
|
Emphasize = scope.Emphasize;
|
|
|
|
|
Required = scope.Required;
|
|
|
|
|
Checked = check || scope.Required;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-13 17:03:23 +05:30
|
|
|
|
public ScopeViewModel(IdentityServer4.Models.IdentityResource identity, bool check)
|
2017-04-05 09:18:14 -03:00
|
|
|
|
{
|
|
|
|
|
Name = identity.Name;
|
|
|
|
|
DisplayName = identity.DisplayName;
|
|
|
|
|
Description = identity.Description;
|
|
|
|
|
Emphasize = identity.Emphasize;
|
|
|
|
|
Required = identity.Required;
|
|
|
|
|
Checked = check || identity.Required;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-16 12:13:14 +01:00
|
|
|
|
public string Name { get; init; }
|
|
|
|
|
public string DisplayName { get; init; }
|
|
|
|
|
public string Description { get; init; }
|
|
|
|
|
public bool Emphasize { get; init; }
|
|
|
|
|
public bool Required { get; init; }
|
|
|
|
|
public bool Checked { get; init; }
|
2016-11-24 15:31:33 +01:00
|
|
|
|
}
|
|
|
|
|
}
|