refactor: 后台管理首页增加匿名访问权限

This commit is contained in:
Argo Windows 2019-10-28 22:59:32 +08:00
parent 0a3c040f9a
commit e16385ddd2
4 changed files with 28 additions and 26 deletions

View File

@ -7,85 +7,85 @@ using System;
namespace Bootstrap.Admin.Controllers namespace Bootstrap.Admin.Controllers
{ {
/// <summary> /// <summary>
/// /// 后台管理控制器
/// </summary> /// </summary>
[Authorize] [Authorize]
public class AdminController : Controller public class AdminController : Controller
{ {
/// <summary> /// <summary>
/// /// 后台管理首页
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Index() => View(new NavigatorBarModel(this)); public ActionResult Index() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 用户维护
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Users() => View(new NavigatorBarModel(this)); public ActionResult Users() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 部门维护
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Groups() => View(new NavigatorBarModel(this)); public ActionResult Groups() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 字典表维护
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Dicts() => View(new NavigatorBarModel(this)); public ActionResult Dicts() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 角色维护
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Roles() => View(new NavigatorBarModel(this)); public ActionResult Roles() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 菜单维护
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Menus() => View(new NavigatorBarModel(this)); public ActionResult Menus() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 操作日志
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Logs() => View(new NavigatorBarModel(this)); public ActionResult Logs() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 脚本日志
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult SQL() => View(new NavigatorBarModel(this)); public ActionResult SQL() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 访问日志
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Traces() => View(new NavigatorBarModel(this)); public ActionResult Traces() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 登录日志
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Logins() => View(new NavigatorBarModel(this)); public ActionResult Logins() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// FA 图标页面
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult FAIcon() => View(new NavigatorBarModel(this)); public ActionResult FAIcon() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 健康检查
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Healths() => View(new NavigatorBarModel(this)); public ActionResult Healths() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 图标视图
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous] [AllowAnonymous]
@ -93,44 +93,44 @@ namespace Bootstrap.Admin.Controllers
public PartialViewResult IconView() => PartialView("IconView"); public PartialViewResult IconView() => PartialView("IconView");
/// <summary> /// <summary>
/// /// 网站设置
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Settings() => View(new SettingsModel(this)); public ActionResult Settings() => View(new SettingsModel(this));
/// <summary> /// <summary>
/// /// 通知管理
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Notifications() => View(new NavigatorBarModel(this)); public ActionResult Notifications() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 个人中心
/// </summary> /// </summary>
/// <param name="host"></param> /// <param name="host"></param>
/// <returns></returns> /// <returns></returns>
public ActionResult Profiles([FromServices]IWebHostEnvironment host) => View(new ProfilesModel(this, host)); public ActionResult Profiles([FromServices]IWebHostEnvironment host) => View(new ProfilesModel(this, host));
/// <summary> /// <summary>
/// /// 程序异常
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Exceptions() => View(new NavigatorBarModel(this)); public ActionResult Exceptions() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 消息通知
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Messages() => View(new NavigatorBarModel(this)); public ActionResult Messages() => View(new NavigatorBarModel(this));
/// <summary> /// <summary>
/// /// 任务管理
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Tasks() => View(new TaskModel(this)); public ActionResult Tasks() => View(new TaskModel(this));
/// <summary> /// <summary>
/// /// 客户端测试页面
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public ActionResult Mobile() => View(new NavigatorBarModel(this)); public ActionResult Mobile() => View(new NavigatorBarModel(this));

View File

@ -9,7 +9,7 @@ namespace Bootstrap.Admin.Controllers
/// <summary> /// <summary>
/// Home Controller /// Home Controller
/// </summary> /// </summary>
[Authorize] [AllowAnonymous]
public class HomeController : Controller public class HomeController : Controller
{ {
/// <summary> /// <summary>
@ -18,7 +18,10 @@ namespace Bootstrap.Admin.Controllers
/// <returns></returns> /// <returns></returns>
public IActionResult Index() public IActionResult Index()
{ {
var model = new HeaderBarModel(User.Identity.Name); 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); if (string.IsNullOrEmpty(model.UserName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LogoutPath);
var homeUrl = DictHelper.RetrieveHomeUrl(model.AppId); var homeUrl = DictHelper.RetrieveHomeUrl(model.AppId);
@ -30,7 +33,6 @@ namespace Bootstrap.Admin.Controllers
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
[AllowAnonymous]
public IActionResult Error(int id) public IActionResult Error(int id)
{ {
var model = ErrorModel.CreateById(id); var model = ErrorModel.CreateById(id);

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta1" /> <PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta2" />
<PackageReference Include="Longbow" Version="3.0.0" /> <PackageReference Include="Longbow" Version="3.0.0" />
<PackageReference Include="Longbow.Cache" Version="3.0.0" /> <PackageReference Include="Longbow.Cache" Version="3.0.0" />
<PackageReference Include="Longbow.Configuration" Version="3.0.0" /> <PackageReference Include="Longbow.Configuration" Version="3.0.0" />

View File

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta1" /> <PackageReference Include="Bootstrap.Security.DataAccess" Version="3.0.1-beta2" />
<PackageReference Include="Longbow" Version="3.0.0" /> <PackageReference Include="Longbow" Version="3.0.0" />
<PackageReference Include="Longbow.Cache" Version="3.0.0" /> <PackageReference Include="Longbow.Cache" Version="3.0.0" />
<PackageReference Include="Longbow.Configuration" Version="3.0.0" /> <PackageReference Include="Longbow.Configuration" Version="3.0.0" />