Consent视图制作
学习分享 丨作者 / 郑 子 铭 丨公众号 / DotNet NB / CloudNative NB
任务19:Consent视图制作
按照上一节 Consent 的思路
在 mvcCookieAuthSample 项目的 Controllers 文件夹下新建一个 ConsentController
在 Views 文件夹下新建一个 Consent 文件夹,然后在该文件夹下新建一个 Index 视图
在 ViewModels 文件夹下新建一个 ConsentViewModel
在 ViewModels 文件夹下新建一个 ScopeViewModel
ScopeViewModel.cs
namespace mvcCookieAuthSample.ViewModels
{
public class ScopeViewModel
{
public string Name { get; set; }
public string DisplayName { get; set; }
public string Description { get; set; }
public string Emphasize { get; set; }
public string Required { get; set; }
public bool Checked { get; set; }
}
}这个定义来自于 IdentityServer4 官方文档中 Identity Resource 和 API Resource 的模型 https://identityserver4.readthedocs.io/en/latest/reference/identity_resource.html

ConsentViewModel.cs
接下来需要把两个 ViewModel 的信息显示在 Index 里面,实现类似微博授权页面

_ScopeListitem.cshtml
Index.cshtml
上半部分展示图标和提示,下半部分分为三部分,分别列出 IdentityScopes 和 ResourceScopes,以及选择是否记住,最后实现授权
Last updated