feat: 更新登录时获取默认应用逻辑
This commit is contained in:
parent
f712b0ab0e
commit
76fe5d7fcd
|
@ -165,7 +165,9 @@ class DictService : IDict
|
|||
{
|
||||
string? url = null;
|
||||
var dicts = GetAll();
|
||||
appId ??= "BA";
|
||||
|
||||
// appId 为空时读取前台列表取第一个应用作为默认应用
|
||||
appId ??= GetApps().FirstOrDefault(d => d.Key != "BA").Key ?? AppId;
|
||||
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -189,8 +189,10 @@ class DictService : BaseDatabase, IDict
|
|||
public string? GetHomeUrlByAppId(string? appId = null)
|
||||
{
|
||||
string? url = null;
|
||||
appId ??= "BA";
|
||||
var dicts = GetAll();
|
||||
|
||||
// appId 为空时读取前台列表取第一个应用作为默认应用
|
||||
appId ??= GetApps().FirstOrDefault(d => d.Key != "BA").Key ?? AppId;
|
||||
url = dicts.FirstOrDefault(d => d.Category == "应用首页" && d.Name.Equals(appId, StringComparison.OrdinalIgnoreCase) && d.Define == EnumDictDefine.System)?.Code;
|
||||
return url;
|
||||
}
|
||||
|
|
|
@ -84,14 +84,17 @@ namespace BootstrapAdmin.Web.Controllers
|
|||
|
||||
private IActionResult RedirectLogin(string? returnUrl = null)
|
||||
{
|
||||
var query = Request.Query.Aggregate(new Dictionary<string, string?>(), (d, v) =>
|
||||
var url = returnUrl;
|
||||
if (string.IsNullOrEmpty(url))
|
||||
{
|
||||
d.Add(v.Key, v.Value.ToString());
|
||||
return d;
|
||||
});
|
||||
return returnUrl == null
|
||||
? Redirect(QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, query))
|
||||
: Redirect(returnUrl);
|
||||
var query = Request.Query.Aggregate(new Dictionary<string, string?>(), (d, v) =>
|
||||
{
|
||||
d.Add(v.Key, v.Value.ToString());
|
||||
return d;
|
||||
});
|
||||
url = QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, query);
|
||||
}
|
||||
return Redirect(url);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -99,14 +102,18 @@ namespace BootstrapAdmin.Web.Controllers
|
|||
/// <summary>
|
||||
/// Logout this instance.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="returnUrl"></param>
|
||||
/// <param name="appId"></param>
|
||||
/// <returns>The logout.</returns>
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Logout([FromServices] BootstrapAppContext context, [FromQuery] string appId)
|
||||
public async Task<IActionResult> Logout([FromQuery] string returnUrl, [FromQuery] string appId)
|
||||
{
|
||||
await HttpContext.SignOutAsync();
|
||||
return Redirect(QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, "AppId", appId ?? context.AppId));
|
||||
return Redirect(QueryHelpers.AddQueryString(Request.PathBase + CookieAuthenticationDefaults.LoginPath, new Dictionary<string, string?>
|
||||
{
|
||||
["AppId"] = appId,
|
||||
["ReturnUrl"] = returnUrl
|
||||
}));
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using BootstrapAdmin.Web.Core;
|
||||
using PetaPoco.Providers;
|
||||
using BootstrapAdmin.Web.Core.Services;
|
||||
using PetaPoco;
|
||||
using System.Text;
|
||||
using PetaPoco.Providers;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyInjection
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue