|
|
|
@ -0,0 +1,43 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Volo.Abp.UI.Navigation;
|
|
|
|
|
using Volo.Abp.Users;
|
|
|
|
|
|
|
|
|
|
namespace BackendAdminApp.Host
|
|
|
|
|
{
|
|
|
|
|
public class BackendAdminAppMenuContributor : IMenuContributor
|
|
|
|
|
{
|
|
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
|
|
|
|
|
|
public BackendAdminAppMenuContributor(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
_configuration = configuration;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
|
|
|
|
|
{
|
|
|
|
|
if (context.Menu.Name == StandardMenus.User)
|
|
|
|
|
{
|
|
|
|
|
await ConfigureUserMenuAsync(context);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
|
|
|
|
|
{
|
|
|
|
|
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
|
|
|
|
|
|
|
|
|
|
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
|
|
|
|
|
|
|
|
|
|
if (currentUser.IsAuthenticated)
|
|
|
|
|
{
|
|
|
|
|
//TODO: Localize menu items
|
|
|
|
|
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", "Manage Your Profile", $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage", icon: "fa fa-cog", order: 1000, null, "_blank"));
|
|
|
|
|
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", "Logout", url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|