mirror of https://github.com/abpframework/abp.git
7 changed files with 67 additions and 27 deletions
@ -0,0 +1,26 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Account.Web.Modules.Account.Components.Toolbar.UserLoginLink; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; |
||||
|
using Volo.Abp.Users; |
||||
|
|
||||
|
namespace Volo.Abp.Account.Web |
||||
|
{ |
||||
|
public class AccountModuleToolbarContributor : IToolbarContributor |
||||
|
{ |
||||
|
public Task ConfigureToolbarAsync(IToolbarConfigurationContext context) |
||||
|
{ |
||||
|
if (context.Toolbar.Name != StandardToolbars.Main) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
if (!context.ServiceProvider.GetRequiredService<ICurrentUser>().IsAuthenticated) |
||||
|
{ |
||||
|
context.Toolbar.Items.Add(new ToolbarItem(typeof(UserLoginLinkViewComponent))); |
||||
|
} |
||||
|
|
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
@using Localization.Resources.AbpUi |
||||
|
@using Microsoft.AspNetCore.Mvc.Localization |
||||
|
@inject IHtmlLocalizer<AbpUiResource> L |
||||
|
<a href="/Account/Login">@L["Login"]</a> |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Volo.Abp.Account.Web.Modules.Account.Components.Toolbar.UserLoginLink |
||||
|
{ |
||||
|
public class UserLoginLinkViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public IViewComponentResult Invoke() |
||||
|
{ |
||||
|
return View("~/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue