mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.8 KiB
60 lines
1.8 KiB
using System;
|
|
using System.Threading.Tasks;
|
|
using Localization.Resources.AbpUi;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Localization;
|
|
using Volo.CmsKit.Localization;
|
|
using Volo.Abp.UI.Navigation;
|
|
using Volo.Abp.Users;
|
|
|
|
namespace Volo.CmsKit
|
|
{
|
|
public class CmsKitWebHostMenuContributor : IMenuContributor
|
|
{
|
|
private readonly IConfiguration _configuration;
|
|
|
|
public CmsKitWebHostMenuContributor(IConfiguration configuration)
|
|
{
|
|
_configuration = configuration;
|
|
}
|
|
|
|
public Task ConfigureMenuAsync(MenuConfigurationContext context)
|
|
{
|
|
if (context.Menu.Name == StandardMenus.User)
|
|
{
|
|
AddLogoutItemToMenu(context);
|
|
}
|
|
|
|
return Task.CompletedTask;
|
|
}
|
|
|
|
private void AddLogoutItemToMenu(MenuConfigurationContext context)
|
|
{
|
|
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
|
|
var l = context.GetLocalizer<CmsKitResource>();
|
|
|
|
if (currentUser.IsAuthenticated)
|
|
{
|
|
context.Menu.Items.Add(new ApplicationMenuItem(
|
|
"Account.Manage",
|
|
l["ManageYourProfile"],
|
|
$"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage",
|
|
icon: "fa fa-cog",
|
|
order: int.MaxValue - 1001,
|
|
null,
|
|
"_blank")
|
|
);
|
|
|
|
|
|
context.Menu.Items.Add(new ApplicationMenuItem(
|
|
"Account.Logout",
|
|
l["Logout"],
|
|
"~/Account/Logout",
|
|
"fas fa-power-off",
|
|
order: int.MaxValue - 1000
|
|
));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|