refactor: 登录用户名不存在逻辑移动到中间件中

This commit is contained in:
Argo Windows 2019-10-31 12:25:18 +08:00
parent 7149bcb61b
commit a02a1474f5
3 changed files with 3 additions and 8 deletions

View File

@ -18,12 +18,7 @@ namespace Bootstrap.Admin.Controllers
/// <returns></returns>
public IActionResult Index()
{
var userName = User.Identity.Name;
if (string.IsNullOrEmpty(userName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LoginPath);
var model = new HeaderBarModel(userName);
if (string.IsNullOrEmpty(model.UserName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LogoutPath);
var model = new HeaderBarModel(User.Identity.Name);
var homeUrl = DictHelper.RetrieveHomeUrl(model.AppId);
return homeUrl.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(model) : Redirect(homeUrl);
}

View File

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta3" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta5" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta6" />
<PackageReference Include="Longbow" Version="3.0.0" />
<PackageReference Include="Longbow.Cache" Version="3.0.1-beta1" />
<PackageReference Include="Longbow.Data" Version="3.0.1-beta1" />

View File

@ -6,7 +6,7 @@
<ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta3" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta5" />
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.2-beta6" />
<PackageReference Include="Longbow" Version="3.0.0" />
<PackageReference Include="Longbow.Cache" Version="3.0.1-beta1" />
<PackageReference Include="Longbow.Data" Version="3.0.1-beta1" />