This commit is contained in:
alex
2023-08-15 16:54:44 +08:00
4 changed files with 18 additions and 10 deletions

View File

@@ -22,6 +22,7 @@ using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System;
using JNPF.VisualDev;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using NPOI.HSSF.UserModel;
@@ -68,9 +69,9 @@ namespace Tnb.WarehouseMgr
}
}
protected Task<ClaimsPrincipal> GetUserIdentity(string aToken)
protected Task<ClaimsPrincipal> GetUserIdentity()
{
var claims = JWTEncryption.ReadJwtToken(aToken)?.Claims;
var claims = JWTEncryption.ReadJwtToken(UserManager.AsscessToken)?.Claims;
ClaimsIdentity toKen = new ClaimsIdentity();
foreach (Claim item in claims)
{

View File

@@ -97,6 +97,8 @@ namespace Tnb.WarehouseMgr
[HttpPost, Timed(Name = nameof(PackSortingByAdd))]
public async Task PackSortingByAdd(CancellationTokenSource? cts = default)
{
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
var curUser = await GetUserIdentity();
var curDb = _db.CopyNew();
string firstLocationId = "27010980724501", secondLocationId = "27010987857941";

View File

@@ -80,6 +80,8 @@ namespace Tnb.WarehouseMgr
[HttpPost, Timed(Name = nameof(KittingOutByAdd))]
public async Task KittingOutByAdd(CancellationTokenSource? cts = default)
{
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
var curUser = await GetUserIdentity();
var curDb = _db.CopyNew();
try
{
@@ -134,8 +136,8 @@ namespace Tnb.WarehouseMgr
setSortingH.id = SnowflakeIdHelper.NextId();
setSortingH.kittingout_id = ko.id;
setSortingH.seq = ko.seq;
setSortingH.org_id = _userManager.User.OrganizeId;
setSortingH.create_id = _userManager.UserId;
setSortingH.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value;
setSortingH.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value;
setSortingH.create_time = DateTime.Now;
await curDb.Insertable(setSortingH).ExecuteCommandAsync();
@@ -146,8 +148,8 @@ namespace Tnb.WarehouseMgr
x.id = SnowflakeIdHelper.NextId();
x.bill_id = setSortingH.id;
x.warehouse_id = setSortingH.warehouse_id;
x.org_id = _userManager.User.OrganizeId;
x.create_id = _userManager.UserId;
x.org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value;
x.create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value;
x.create_time = DateTime.Now;
});
await curDb.Insertable(setSortDetails).ExecuteCommandAsync();
@@ -175,6 +177,8 @@ namespace Tnb.WarehouseMgr
[HttpPost, Timed(Name = nameof(KittingOutByIsToBeShipped))]
public async Task KittingOutByIsToBeShipped(CancellationTokenSource? cts = default)
{
if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
var curUser = await GetUserIdentity();
var curDb = _db.CopyNew();
try
{
@@ -213,7 +217,7 @@ namespace Tnb.WarehouseMgr
WmsPretaskH preTask = new()
{
org_id = _userManager.User.OrganizeId,
org_id = curUser.FindFirst(ClaimConst.CLAINMORGID)?.Value,
startlocation_id = sPoint?.location_id!,
startlocation_code = sPoint?.location_code!,
endlocation_id = ePoint?.location_id!,
@@ -234,7 +238,7 @@ namespace Tnb.WarehouseMgr
area_code = it.Key,
require_id = ko.id,
require_code = ko.bill_code,
create_id = _userManager.UserId,
create_id = curUser.FindFirst(ClaimConst.CLAINMUSERID)!.Value,
create_time = DateTime.Now,
source_id = ko.source_id,
source_code = ko.source_code

View File

@@ -386,7 +386,7 @@ public class OAuthService : IDynamicApiController, ITransient
[HttpGet("Logout")]
public async Task Logout([FromQuery] string ticket)
{
await _cacheManager.DelAsync("AsscessToken");
//await _cacheManager.DelAsync("AsscessToken");
var tenantId = _userManager.TenantId ?? "default";
var userId = _userManager.UserId ?? "admim";
@@ -607,7 +607,8 @@ public class OAuthService : IDynamicApiController, ITransient
}, tokenTimeout);
//modify by ly on 20230804
await _cacheManager.SetAsync("AsscessToken", accessToken, TimeSpan.FromMinutes(-1));
UserManager.AsscessToken = accessToken;
//await _cacheManager.SetAsync("AsscessToken", accessToken, TimeSpan.FromMinutes(-1));
// 单点登录标识缓存
if (_oauthOptions.Enabled) _cacheManager.Set("OnlineTicket_" + input.online_ticket, options.ConfigId);