fix(#IVYHA): UserAgent字符串引发解析OS/Browser异常
升级Longbow.Web组件到2.2.11,数据库增加UserAgent字段保存相关UserAgent comment #IVYHA close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IVYHA
This commit is contained in:
parent
05374f7794
commit
9fc8e53fc5
|
@ -13,7 +13,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.4" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.5" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
|
||||
|
|
Binary file not shown.
|
@ -69,11 +69,12 @@ namespace Bootstrap.Admin.Controllers
|
|||
/// <param name="loginUser"></param>
|
||||
internal static void CreateLoginUser(IOnlineUsers onlineUserSvr, IIPLocatorProvider ipLocator, HttpContext context, LoginUser loginUser)
|
||||
{
|
||||
var agent = new UserAgent(context.Request.Headers["User-Agent"]);
|
||||
loginUser.UserAgent = context.Request.Headers["User-Agent"];
|
||||
var agent = new UserAgent(loginUser.UserAgent);
|
||||
loginUser.Ip = (context.Connection.RemoteIpAddress ?? IPAddress.IPv6Loopback).ToString();
|
||||
loginUser.City = ipLocator.Locate(loginUser.Ip);
|
||||
loginUser.Browser = $"{agent.Browser.Name} {agent.Browser.Version}";
|
||||
loginUser.OS = $"{agent.OS.Name} {agent.OS.Version}";
|
||||
loginUser.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
||||
loginUser.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -35,10 +35,11 @@ namespace Bootstrap.Admin.Controllers.Api
|
|||
[HttpPost]
|
||||
public bool Post([FromServices]IOnlineUsers onlineUserSvr, [FromServices]IIPLocatorProvider ipLocator, [FromBody]Log value)
|
||||
{
|
||||
var agent = new UserAgent(Request.Headers["User-Agent"]);
|
||||
value.UserAgent = Request.Headers["User-Agent"];
|
||||
var agent = new UserAgent(value.UserAgent);
|
||||
value.Ip = (HttpContext.Connection.RemoteIpAddress ?? IPAddress.IPv6Loopback).ToString();
|
||||
value.Browser = $"{agent.Browser.Name} {agent.Browser.Version}";
|
||||
value.OS = $"{agent.OS.Name} {agent.OS.Version}";
|
||||
value.Browser = $"{agent.Browser?.Name} {agent.Browser?.Version}";
|
||||
value.OS = $"{agent.OS?.Name} {agent.OS?.Version}";
|
||||
value.City = ipLocator.Locate(value.Ip);
|
||||
value.UserName = User.Identity.Name;
|
||||
return LogHelper.Save(value);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<PackageReference Include="Bootstrap.Security.DataAccess" Version="2.1.0" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.7" />
|
||||
<PackageReference Include="Longbow.Data" Version="2.2.8" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.10" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.11" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.4" />
|
||||
<PackageReference Include="Bootstrap.Security.Mvc" Version="2.2.5" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<PackageReference Include="Longbow.Data" Version="2.2.8" />
|
||||
<PackageReference Include="Longbow.Logging" Version="2.2.6" />
|
||||
<PackageReference Include="Longbow.Security.Cryptography" Version="1.3.0" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.10" />
|
||||
<PackageReference Include="Longbow.Web" Version="2.2.11" />
|
||||
<PackageReference Include="Longbow.Cache" Version="2.2.7" />
|
||||
<PackageReference Include="Longbow" Version="2.2.9" />
|
||||
<PackageReference Include="Microsoft.Data.Sqlite" Version="2.2.4" />
|
||||
|
|
|
@ -30,7 +30,8 @@ namespace Bootstrap.DataAccess
|
|||
City = v.Location,
|
||||
Browser = v.Browser,
|
||||
OS = v.OS,
|
||||
UserName = v.UserName
|
||||
UserName = v.UserName,
|
||||
UserAgent = v.UserAgent
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public string CRUD { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 获得/设置 请求数据
|
||||
/// <summary>
|
||||
/// 获得/设置 请求数据
|
||||
/// </summary>
|
||||
public string RequestData { get; set; }
|
||||
|
||||
|
|
|
@ -50,6 +50,11 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public string Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
|
|
@ -49,6 +49,11 @@ namespace Bootstrap.DataAccess
|
|||
/// </summary>
|
||||
public string RequestUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string UserAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 保存访问历史记录
|
||||
/// </summary>
|
||||
|
|
|
@ -273,6 +273,7 @@ CREATE TABLE [dbo].[Logs](
|
|||
[City] [nvarchar](50) NULL,
|
||||
[RequestUrl] [nvarchar](500) NOT NULL,
|
||||
[RequestData] [nvarchar](500) NULL,
|
||||
[UserAgent] [varchar](2000) NULL,
|
||||
CONSTRAINT [PK_Logs] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
@ -499,6 +500,7 @@ CREATE TABLE [dbo].[LoginLogs](
|
|||
[Browser] [varchar](50) NULL,
|
||||
[City] [nvarchar](50) NULL,
|
||||
[Result] [nvarchar](50) NOT NULL,
|
||||
[UserAgent] [varchar](2000) NULL,
|
||||
CONSTRAINT [PK_LoginLogs] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
@ -556,6 +558,7 @@ CREATE TABLE [dbo].[Traces](
|
|||
[OS] [varchar](50) NULL,
|
||||
[City] [nvarchar](50) NULL,
|
||||
[RequestUrl] [nvarchar](500) NOT NULL,
|
||||
[UserAgent] [varchar](2000) NULL,
|
||||
CONSTRAINT [PK_Traces] PRIMARY KEY CLUSTERED
|
||||
(
|
||||
[ID] ASC
|
||||
|
|
|
@ -87,7 +87,8 @@ CREATE TABLE Logs(
|
|||
OS VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
RequestData VARCHAR (500) NULL
|
||||
RequestData VARCHAR (500) NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE `Groups`(
|
||||
|
@ -158,7 +159,8 @@ CREATE TABLE LoginLogs(
|
|||
OS VARCHAR (50) NULL,
|
||||
Browser VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
Result VARCHAR (50) NOT NULL
|
||||
Result VARCHAR (50) NOT NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ResetUsers(
|
||||
|
@ -177,5 +179,6 @@ CREATE TABLE Traces(
|
|||
Browser VARCHAR (50),
|
||||
OS VARCHAR (50),
|
||||
City VARCHAR (50),
|
||||
RequestUrl VARCHAR (500) NOT NULL
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
|
@ -87,7 +87,8 @@ CREATE TABLE Logs(
|
|||
OS VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
RequestData VARCHAR (500) NULL
|
||||
RequestData VARCHAR (500) NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE Groups(
|
||||
|
@ -158,7 +159,8 @@ CREATE TABLE RejectUsers(
|
|||
OS VARCHAR (50) NULL,
|
||||
Browser VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
Result VARCHAR (50) NOT NULL
|
||||
Result VARCHAR (50) NOT NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ResetUsers(
|
||||
|
@ -177,5 +179,6 @@ CREATE TABLE Traces(
|
|||
Browser VARCHAR (50),
|
||||
OS VARCHAR (50),
|
||||
City VARCHAR (50),
|
||||
RequestUrl VARCHAR (500) NOT NULL
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
|
@ -87,7 +87,8 @@ CREATE TABLE Logs(
|
|||
OS VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
RequestData VARCHAR (500) NULL
|
||||
RequestData VARCHAR (500) NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE Groups(
|
||||
|
@ -158,7 +159,8 @@ CREATE TABLE LoginLogs(
|
|||
OS VARCHAR (50) NULL,
|
||||
Browser VARCHAR (50) NULL,
|
||||
City VARCHAR (50) NULL,
|
||||
Result VARCHAR (50) NOT NULL
|
||||
Result VARCHAR (50) NOT NULL,
|
||||
UserAgent VARCHAR (2000) NULL
|
||||
);
|
||||
|
||||
CREATE TABLE ResetUsers(
|
||||
|
@ -177,5 +179,6 @@ CREATE TABLE Traces(
|
|||
Browser VARCHAR (50),
|
||||
OS VARCHAR (50),
|
||||
City VARCHAR (50),
|
||||
RequestUrl VARCHAR (500) NOT NULL
|
||||
RequestUrl VARCHAR (500) NOT NULL,
|
||||
UserAgent VARCHAR (2000)
|
||||
);
|
Binary file not shown.
Loading…
Reference in New Issue