commit
99b5b00ac3
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.21" />
|
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.2.21" />
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.0" />
|
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.1-beta1" />
|
||||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||||
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
||||||
<PackageReference Include="Longbow.Tasks" Version="2.2.24" />
|
<PackageReference Include="Longbow.Tasks" Version="2.2.24" />
|
||||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.WebUtilities;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -67,16 +68,17 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 系统登录方法
|
/// 系统登录方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ActionResult Login()
|
public ActionResult Login([FromQuery] string appId = "0")
|
||||||
{
|
{
|
||||||
if (DictHelper.RetrieveSystemModel())
|
if (DictHelper.RetrieveSystemModel())
|
||||||
{
|
{
|
||||||
ViewBag.UserName = "Admin";
|
ViewBag.UserName = "Admin";
|
||||||
ViewBag.Password = "123789";
|
ViewBag.Password = "123789";
|
||||||
}
|
}
|
||||||
return User.Identity.IsAuthenticated ? (ActionResult)Redirect("~/Home/Index") : View("Login", new LoginModel());
|
return User.Identity.IsAuthenticated ? (ActionResult)Redirect("~/Home/Index") : View("Login", new LoginModel(appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -125,12 +127,13 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// <param name="userName">User name.</param>
|
/// <param name="userName">User name.</param>
|
||||||
/// <param name="password">Password.</param>
|
/// <param name="password">Password.</param>
|
||||||
/// <param name="remember">Remember.</param>
|
/// <param name="remember">Remember.</param>
|
||||||
|
/// <param name="appId"></param>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> Login(string userName, string password, string remember)
|
public async Task<IActionResult> Login(string userName, string password, string remember, string appId = "0")
|
||||||
{
|
{
|
||||||
var auth = UserHelper.Authenticate(userName, password);
|
var auth = UserHelper.Authenticate(userName, password);
|
||||||
HttpContext.Log(userName, auth);
|
HttpContext.Log(userName, auth);
|
||||||
return auth ? await SignInAsync(userName, remember == "true") : View("Login", new LoginModel() { AuthFailed = true });
|
return auth ? await SignInAsync(userName, remember == "true") : View("Login", new LoginModel(appId) { AuthFailed = true });
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<IActionResult> SignInAsync(string userName, bool persistent, string authenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme)
|
private async Task<IActionResult> SignInAsync(string userName, bool persistent, string authenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme)
|
||||||
|
@ -163,12 +166,13 @@ namespace Bootstrap.Admin.Controllers
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Logout this instance.
|
/// Logout this instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns>The logout.</returns>
|
/// <returns>The logout.</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<IActionResult> Logout()
|
public async Task<IActionResult> Logout([FromQuery]string appId = "0")
|
||||||
{
|
{
|
||||||
await HttpContext.SignOutAsync();
|
await HttpContext.SignOutAsync();
|
||||||
return Redirect(Request.PathBase + CookieAuthenticationDefaults.LoginPath);
|
return Redirect(QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, "AppId", appId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Bootstrap.Admin.Controllers
|
||||||
{
|
{
|
||||||
var model = new HeaderBarModel(User.Identity);
|
var model = new HeaderBarModel(User.Identity);
|
||||||
if (string.IsNullOrEmpty(model.UserName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LogoutPath);
|
if (string.IsNullOrEmpty(model.UserName)) return Redirect(Request.PathBase + CookieAuthenticationDefaults.LogoutPath);
|
||||||
var url = DictHelper.RetrieveHomeUrl(model.AppCode);
|
var url = DictHelper.RetrieveHomeUrl(model.AppId);
|
||||||
return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(model) : Redirect(url);
|
return url.Equals("~/Home/Index", System.StringComparison.OrdinalIgnoreCase) ? (IActionResult)View(model) : Redirect(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,9 +21,13 @@ namespace Bootstrap.Admin.Models
|
||||||
Icon = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : string.Format("{0}{1}", DictHelper.RetrieveIconFolderPath(), user.Icon);
|
Icon = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : string.Format("{0}{1}", DictHelper.RetrieveIconFolderPath(), user.Icon);
|
||||||
DisplayName = user.DisplayName;
|
DisplayName = user.DisplayName;
|
||||||
UserName = user.UserName;
|
UserName = user.UserName;
|
||||||
AppCode = user.App;
|
AppId = user.App;
|
||||||
Css = user.Css;
|
Css = user.Css;
|
||||||
ActiveCss = string.IsNullOrEmpty(Css) ? Theme : Css;
|
ActiveCss = string.IsNullOrEmpty(Css) ? Theme : Css;
|
||||||
|
|
||||||
|
// 通过 AppCode 获取用户默认应用的标题
|
||||||
|
Title = DictHelper.RetrieveWebTitle(AppId);
|
||||||
|
Footer = DictHelper.RetrieveWebFooter(AppId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +54,7 @@ namespace Bootstrap.Admin.Models
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得 当前设置的默认应用
|
/// 获得 当前设置的默认应用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string AppCode { get; }
|
public string AppId { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得 当前样式
|
/// 获得 当前样式
|
||||||
|
|
|
@ -10,7 +10,8 @@ namespace Bootstrap.Admin.Models
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认构造函数
|
/// 默认构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public LoginModel()
|
/// <param name="appId"></param>
|
||||||
|
public LoginModel(string appId = "0") : base(appId)
|
||||||
{
|
{
|
||||||
ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
|
ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,11 @@ namespace Bootstrap.Admin.Models
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认构造函数
|
/// 默认构造函数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ModelBase()
|
/// <param name="appId"></param>
|
||||||
|
public ModelBase(string appId = "0")
|
||||||
{
|
{
|
||||||
Title = DictHelper.RetrieveWebTitle();
|
Title = DictHelper.RetrieveWebTitle(appId);
|
||||||
Footer = DictHelper.RetrieveWebFooter();
|
Footer = DictHelper.RetrieveWebFooter(appId);
|
||||||
Theme = DictHelper.RetrieveActiveTheme();
|
Theme = DictHelper.RetrieveActiveTheme();
|
||||||
IsDemo = DictHelper.RetrieveSystemModel();
|
IsDemo = DictHelper.RetrieveSystemModel();
|
||||||
ShowCardTitle = DictHelper.RetrieveCardTitleStatus() ? "" : "no-card-header";
|
ShowCardTitle = DictHelper.RetrieveCardTitleStatus() ? "" : "no-card-header";
|
||||||
|
@ -26,15 +27,23 @@ namespace Bootstrap.Admin.Models
|
||||||
EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen();
|
EnableAutoLockScreen = DictHelper.RetrieveAutoLockScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 默认构造函数
|
||||||
|
/// </summary>
|
||||||
|
public ModelBase() : this("0")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取 网站标题
|
/// 获取 网站标题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Title { get; private set; }
|
public string Title { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取 网站页脚
|
/// 获取 网站页脚
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Footer { get; private set; }
|
public string Footer { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 网站样式全局设置
|
/// 网站样式全局设置
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="btn-group" role="group">
|
<div class="btn-group" role="group">
|
||||||
<button id="app" class="btn btn-success dropdown-select dropdown-toggle" data-toggle="dropdown" data-default-val="" value="@Model.AppCode">未设置</button>
|
<button id="app" class="btn btn-success dropdown-select dropdown-toggle" data-toggle="dropdown" data-default-val="" value="@Model.AppId">未设置</button>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
@foreach (var app in Model.Applications)
|
@foreach (var app in Model.Applications)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,7 +112,7 @@
|
||||||
<a href="~/Admin/Notifications"><i class="fa fa-bell"></i>通知<span id="logoutNoti" class="badge badge-pill badge-success"></span></a>
|
<a href="~/Admin/Notifications"><i class="fa fa-bell"></i>通知<span id="logoutNoti" class="badge badge-pill badge-success"></span></a>
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-item">
|
<div class="dropdown-item">
|
||||||
<a href="~/Account/Logout"><i class="fa fa-key"></i>注销</a>
|
<a href="~/Account/Logout?appId=@Model.AppId"><i class="fa fa-key"></i>注销</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -74,21 +74,23 @@ namespace Bootstrap.DataAccess.MongoDB
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 获得网站标题设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override string RetrieveWebTitle()
|
public override string RetrieveWebTitle(string appId = "0")
|
||||||
{
|
{
|
||||||
var code = RetrieveAppName("网站标题");
|
var code = RetrieveAppName("网站标题", appId);
|
||||||
if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
|
if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 获得网站页脚设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override string RetrieveWebFooter()
|
public override string RetrieveWebFooter(string appId = "0")
|
||||||
{
|
{
|
||||||
var code = RetrieveAppName("网站页脚");
|
var code = RetrieveAppName("网站页脚");
|
||||||
if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
|
if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
|
||||||
|
|
|
@ -63,11 +63,13 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取系统网站标题
|
/// 获取系统网站标题
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveWebTitle()
|
public virtual string RetrieveWebTitle(string appId = "0")
|
||||||
{
|
{
|
||||||
// 优先查找配置的应用程序网站标题
|
// 优先查找配置的应用程序网站标题
|
||||||
var code = DbHelper.RetrieveTitle();
|
var code = DbHelper.RetrieveTitle(appId);
|
||||||
|
|
||||||
if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
|
if (code == "网站标题未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站标题" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "后台管理系统";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -75,11 +77,12 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取系统网站页脚
|
/// 获取系统网站页脚
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public virtual string RetrieveWebFooter()
|
public virtual string RetrieveWebFooter(string appId = "0")
|
||||||
{
|
{
|
||||||
// 优先查找配置的应用程序网站标题
|
// 优先查找配置的应用程序网站标题
|
||||||
var code = DbHelper.RetrieveFooter();
|
var code = DbHelper.RetrieveFooter(appId);
|
||||||
if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
|
if (code == "网站页脚未设置") code = DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "网站页脚" && d.Category == "网站设置" && d.Define == 0)?.Code ?? "2016 © 通用后台管理系统";
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,14 +98,16 @@ namespace Bootstrap.DataAccess
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取站点 Title 配置信息
|
/// 获取站点 Title 配置信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string RetrieveWebTitle() => DbContextManager.Create<Dict>().RetrieveWebTitle();
|
public static string RetrieveWebTitle(string appId = "0") => DbContextManager.Create<Dict>().RetrieveWebTitle(appId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取站点 Footer 配置信息
|
/// 获取站点 Footer 配置信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="appId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string RetrieveWebFooter() => DbContextManager.Create<Dict>().RetrieveWebFooter();
|
public static string RetrieveWebFooter(string appId = "0") => DbContextManager.Create<Dict>().RetrieveWebFooter(appId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获得系统中配置的可以使用的网站样式
|
/// 获得系统中配置的可以使用的网站样式
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.0" />
|
<PackageReference Include="Bootstrap.Security.Mvc" Version="3.0.1-beta1" />
|
||||||
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
<PackageReference Include="Longbow.Configuration" Version="2.2.7" />
|
||||||
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
<PackageReference Include="Longbow.Logging" Version="3.0.0" />
|
||||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
<PackageReference Include="Microsoft.Data.Sqlite" Version="3.0.0" />
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace Bootstrap.Client.Models
|
||||||
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost;
|
var authHost = ConfigurationManager.Get<BootstrapAdminAuthenticationOptions>().AuthHost;
|
||||||
var uriBuilder = new UriBuilder(authHost);
|
var uriBuilder = new UriBuilder(authHost);
|
||||||
uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}";
|
uriBuilder.Path = uriBuilder.Path == "/" ? CookieAuthenticationDefaults.LogoutPath.Value : $"{uriBuilder.Path.TrimEnd('/')}{CookieAuthenticationDefaults.LogoutPath.Value}";
|
||||||
|
uriBuilder.Query = $"AppId={AppId}";
|
||||||
LogoutUrl = uriBuilder.ToString();
|
LogoutUrl = uriBuilder.ToString();
|
||||||
|
|
||||||
// set Icon
|
// set Icon
|
||||||
|
|
|
@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
|
Loading…
Reference in New Issue