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

View File

@ -9,7 +9,7 @@ namespace Bootstrap.Admin.Controllers
/// <summary>
/// Home Controller
/// </summary>
[Authorize]
[AllowAnonymous]
public class HomeController : Controller
{
/// <summary>
@ -18,7 +18,10 @@ namespace Bootstrap.Admin.Controllers
/// <returns></returns>
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);
var homeUrl = DictHelper.RetrieveHomeUrl(model.AppId);
@ -30,7 +33,6 @@ namespace Bootstrap.Admin.Controllers
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[AllowAnonymous]
public IActionResult Error(int id)
{
var model = ErrorModel.CreateById(id);

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<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.Cache" Version="3.0.0" />
<PackageReference Include="Longbow.Configuration" Version="3.0.0" />

View File

@ -5,7 +5,7 @@
</PropertyGroup>
<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.Cache" Version="3.0.0" />
<PackageReference Include="Longbow.Configuration" Version="3.0.0" />