⚡优化功能
This commit is contained in:
parent
6533020ebc
commit
55733f07e8
@ -52,7 +52,7 @@ namespace Infrastructure.Extensions
|
|||||||
if (result.Contains("::1"))
|
if (result.Contains("::1"))
|
||||||
result = "127.0.0.1";
|
result = "127.0.0.1";
|
||||||
|
|
||||||
result = result.Replace("::ffff:", "127.0.0.1");
|
result = result.Replace("::ffff:", "");
|
||||||
result = result.Split(':')?.FirstOrDefault() ?? "127.0.0.1";
|
result = result.Split(':')?.FirstOrDefault() ?? "127.0.0.1";
|
||||||
result = IsIP(result) ? result : "127.0.0.1";
|
result = IsIP(result) ? result : "127.0.0.1";
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -74,7 +74,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
return ToResponse(ResultCode.CAPTCHA_ERROR, "验证码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
var lockTimeStamp = CacheService.GetLockUser(loginBody.ClientId);
|
var lockTimeStamp = CacheService.GetLockUser(loginBody.ClientId + loginBody.Username);
|
||||||
var lockTime = DateTimeHelper.ToLocalTimeDateBySeconds(lockTimeStamp);
|
var lockTime = DateTimeHelper.ToLocalTimeDateBySeconds(lockTimeStamp);
|
||||||
var ts = lockTime - DateTime.Now;
|
var ts = lockTime - DateTime.Now;
|
||||||
|
|
||||||
@ -278,7 +278,15 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||||||
public IActionResult ScanLogin([FromBody] ScanDto dto)
|
public IActionResult ScanLogin([FromBody] ScanDto dto)
|
||||||
{
|
{
|
||||||
if (dto == null) { return ToResponse(ResultCode.CUSTOM_ERROR, "扫码失败"); }
|
if (dto == null) { return ToResponse(ResultCode.CUSTOM_ERROR, "扫码失败"); }
|
||||||
|
var name = App.HttpContext.GetName();
|
||||||
|
var lockTimeStamp = CacheService.GetLockUser(dto.DeviceId + name);
|
||||||
|
var lockTime = DateTimeHelper.ToLocalTimeDateBySeconds(lockTimeStamp);
|
||||||
|
var ts = lockTime - DateTime.Now;
|
||||||
|
|
||||||
|
if (lockTimeStamp > 0 && ts.TotalSeconds > 0)
|
||||||
|
{
|
||||||
|
return ToResponse(ResultCode.LOGIN_ERROR, $"当前设备已被锁,剩余{Math.Round(ts.TotalMinutes, 0)}分钟");
|
||||||
|
}
|
||||||
var token = HttpContextExtension.GetToken(HttpContext);
|
var token = HttpContextExtension.GetToken(HttpContext);
|
||||||
if (CacheService.GetScanLogin(dto.Uuid) is not null)
|
if (CacheService.GetScanLogin(dto.Uuid) is not null)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -50,8 +50,8 @@ namespace ZR.Admin.WebApi.Controllers.monitor
|
|||||||
await HubContext.Clients.Client(dto.ConnnectionId).SendAsync(HubsConstant.LockUser, new { dto.Reason, dto.Time });
|
await HubContext.Clients.Client(dto.ConnnectionId).SendAsync(HubsConstant.LockUser, new { dto.Reason, dto.Time });
|
||||||
|
|
||||||
var expirTime = DateTimeHelper.GetUnixTimeSeconds(DateTime.Now.AddMinutes(dto.Time));
|
var expirTime = DateTimeHelper.GetUnixTimeSeconds(DateTime.Now.AddMinutes(dto.Time));
|
||||||
|
//PC 端采用设备 + 用户名的方式进行封锁
|
||||||
CacheService.SetLockUser(dto.ClientId, expirTime, dto.Time);
|
CacheService.SetLockUser(dto.ClientId + dto.Name, expirTime, dto.Time);
|
||||||
return SUCCESS(new { expirTime });
|
return SUCCESS(new { expirTime });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,8 @@
|
|||||||
using Infrastructure;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Infrastructure.Extensions;
|
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using ZR.Admin.WebApi.Extensions;
|
|
||||||
using ZR.Model.System.Dto;
|
using ZR.Model.System.Dto;
|
||||||
using ZR.Service.System;
|
using ZR.Service.System;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@ using IPTools.Core;
|
|||||||
using Microsoft.AspNetCore.SignalR;
|
using Microsoft.AspNetCore.SignalR;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using UAParser;
|
using UAParser;
|
||||||
using ZR.Admin.WebApi.Extensions;
|
|
||||||
using ZR.Service.System.IService;
|
using ZR.Service.System.IService;
|
||||||
|
|
||||||
namespace ZR.Admin.WebApi.Hubs
|
namespace ZR.Admin.WebApi.Hubs
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
{
|
{
|
||||||
public class LockUserDto
|
public class LockUserDto
|
||||||
{
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
public string ClientId { get; set; }
|
public string ClientId { get; set; }
|
||||||
public string ConnnectionId { get; set; }
|
public string ConnnectionId { get; set; }
|
||||||
public string Reason { get; set; }
|
public string Reason { get; set; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user