diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml index c799ba25b8..8ba998785e 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml @@ -7,27 +7,20 @@ @inject ICurrentTenant CurrentTenant @inject IHtmlLocalizer L @model ApplicationMenu -@if (CurrentUser.IsAuthenticated) -{ - \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs index 3c86a68a82..dea0ea73d2 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Options; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.UserMenu; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; +using Volo.Abp.Users; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Toolbars { @@ -30,7 +31,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Toolbars context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitchViewComponent))); } - context.Toolbar.Items.Add(new ToolbarItem(typeof(UserMenuViewComponent))); + if (context.ServiceProvider.GetRequiredService().IsAuthenticated) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(UserMenuViewComponent))); + } return Task.CompletedTask; } diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs index d212310648..9f1533409a 100644 --- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs +++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs @@ -3,7 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Account.Web.Localization; using Volo.Abp.Account.Web.Settings; using Volo.Abp.AspNetCore.Mvc.Localization; -using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.Identity; using Volo.Abp.Localization; using Volo.Abp.Localization.Resources.AbpValidation; @@ -15,7 +15,7 @@ using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.Account.Web { [DependsOn(typeof(AbpIdentityDomainModule))] - [DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))] + [DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))] public class AbpAccountWebModule : AbpModule { public override void PreConfigureServices(IServiceCollection services) diff --git a/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs b/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs new file mode 100644 index 0000000000..9302b5aefd --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/AccountModuleToolbarContributor.cs @@ -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().IsAuthenticated) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(UserLoginLinkViewComponent))); + } + + return Task.CompletedTask; + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml new file mode 100644 index 0000000000..451a65b2dc --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/Default.cshtml @@ -0,0 +1,4 @@ +@using Localization.Resources.AbpUi +@using Microsoft.AspNetCore.Mvc.Localization +@inject IHtmlLocalizer L +@L["Login"] diff --git a/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLogoutViewComponent.cs b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLogoutViewComponent.cs new file mode 100644 index 0000000000..888f8c2925 --- /dev/null +++ b/modules/account/src/Volo.Abp.Account.Web/Modules/Account/Components/Toolbar/UserLoginLink/UserLogoutViewComponent.cs @@ -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"); + } + } +} diff --git a/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj b/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj index f5f2721af4..3e05644eb4 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj +++ b/modules/account/src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.csproj @@ -22,8 +22,8 @@ - - + +