Add Logout to backend app.

pull/3032/head
Halil İbrahim Kalkan 5 years ago
parent 1c07d20c97
commit dbdea97738

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

@ -24,6 +24,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement;
using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.Web;
using Volo.Abp.UI.Navigation;
using Volo.Blogging;
namespace BackendAdminApp.Host
@ -60,6 +61,11 @@ namespace BackendAdminApp.Host
options.IsEnabled = MsDemoConsts.IsMultiTenancyEnabled;
});
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new BackendAdminAppMenuContributor(configuration));
});
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";

@ -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;
}
}
}

@ -0,0 +1,9 @@
using Volo.Abp.AspNetCore.Mvc.Authentication;
namespace BackendAdminApp.Host.Controllers
{
public class AccountController : ChallengeAccountController
{
}
}
Loading…
Cancel
Save