Browse Source

Change IdentityServer Index page

pull/13026/head
Enis Necipoglu 4 years ago
parent
commit
a90470cf28
  1. 119
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml
  2. 19
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs

119
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml

@ -1,34 +1,103 @@
@page
@using Microsoft.AspNetCore.Mvc.Localization
@using MyCompanyName.MyProjectName.Pages
@using MyCompanyName.MyProjectName.Localization
@using Volo.Abp.Users
@using Volo.Abp.AspNetCore.Mvc.UI.Theming
@using Volo.Abp.Ui.Branding
@model IndexModel
@inject IHtmlLocalizer<MyProjectNameResource> L
@inject ICurrentUser CurrentUser
@if (CurrentUser.IsAuthenticated)
{
<div>
@inject IBrandingProvider BrandingProvider
@inject ITheme Theme
@{
Layout = Theme.GetEmptyLayout();
}
<div class="d-flex align-items-center" style="min-height: 100vh;">
<div class="container">
<abp-row>
<abp-column size-md="_3" class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
<a abp-button="Primary" href="/Account/Logout">Logout</a>
</abp-column>
<abp-column size-md="_9">
<h2>@CurrentUser.UserName</h2>
<h5 class="text-muted">@CurrentUser.Email</h5>
<div>
<strong>Roles</strong>: @CurrentUser.Roles.JoinAsString(", ")
<br />
<strong>Claims</strong>: <br />
@Html.Raw(CurrentUser.GetAllClaims().Select(c => $"{c.Type}={c.Value}").JoinAsString(" <br /> "))
<div class="col mx-auto account-column">
<div class="account-brand p-4 text-center mb-1">
@if (!BrandingProvider.LogoUrl.IsNullOrEmpty())
{
<a class="navbar-brand" href="/" alt="@BrandingProvider.AppName"></a>
}
else
{
<h1>@BrandingProvider.AppName</h1>
}
</div>
</abp-column>
</abp-row>
</div>
}
<abp-card>
<abp-card-body>
<div class="container">
<div class="d-flex align-items-center">
<div class="me-3">
<i class="fa fa-user d-block" style="font-size: 10em; color: #12b900"></i>
</div>
<div>
@if (CurrentUser.IsAuthenticated)
{
<span class="fs-16">
@L["Welcome"] <span class="fw-7">@CurrentUser.UserName</span>
</span>
<span class="fs-14 d-block text-dark-800 opacity-75 mb-1">@CurrentUser.Email</span>
<div class="d-grid gap-2">
<a abp-button="Outline_Primary" asp-controller="Manage" asp-action="Index" asp-area="Account">@L["MyAccount"]</a>
<a abp-button="Primary" asp-controller="Logout" asp-action="Index" asp-area="Account">@L["Logout"]</a>
</div>
}
else
{
<a abp-button="Primary" asp-controller="Login" asp-action="Index" asp-area="Account">@L["Login"]</a>
}
</div>
</div>
@if (!CurrentUser.IsAuthenticated)
{
<div class="text-center">
<i class="fa fa-user d-block" style="font-size: 10em; color: #aaa"></i><br/><br />
<a abp-button="Primary" asp-page="/Account/Login">Login</a>
<hr class="m-4" />
<abp-row>
@foreach (var client in Model.Clients.Where(x => x.RedirectUris.Count > 0))
{
<abp-column size-md="_4" class="mb-2">
<abp-card>
<abp-card-body>
@if (!client.LogoUri.IsNullOrEmpty())
{
<div class="mx-auto text-center">
<img src="@client.LogoUri" />
</div>
}
<h4>@client.ClientName</h4>
@{
var redirectUri = new Uri(@client.RedirectUris.First().RedirectUri);
var url = @redirectUri.AbsoluteUri.RemovePostFix(redirectUri.AbsolutePath);
}
<span class="text-muted">@url</span>
<div class="mt-1">
<a abp-button="Outline_Secondary" href="@url">Visit</a>
</div>
</abp-card-body>
</abp-card>
</abp-column>
}
</abp-row>
</div>
</abp-card-body>
</abp-card>
</div>
</abp-row>
</div>
}
</div>

19
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs

@ -1,10 +1,25 @@
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
using IdentityServer4.Stores;
using Volo.Abp.IdentityServer.Clients;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : AbpPageModel
{
public void OnGet()
public List<Client> Clients { get; protected set; }
// TODO: Consider using IClientStore here.
protected IClientRepository ClientRepository { get; }
public IndexModel(IClientRepository clientRepository)
{
this.ClientRepository = clientRepository;
}
public async Task OnGetAsync()
{
Clients = await ClientRepository.GetListAsync(includeDetails: true);
}
}
}
Loading…
Cancel
Save