Uat_Study
hang 2022-05-27 14:03:48 +08:00
parent 0c1feb3c5a
commit 938924ebe1
2 changed files with 99 additions and 58 deletions

View File

@ -1,12 +1,14 @@
using Invio.Extensions.Authentication.JwtBearer;
using IRaCIS.Core.Application.Auth;
using IRaCIS.Core.Application.Auth;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
using Microsoft.IdentityModel.Tokens;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IRaCIS.Core.API
{
@ -37,19 +39,46 @@ namespace IRaCIS.Core.API
ClockSkew = TimeSpan.Zero
};
options.Events = new JwtBearerEvents
{
OnMessageReceived = (context) =>
{
if (!context.Request.Query.TryGetValue("access_token", out StringValues values))
{
return Task.CompletedTask;
}
var queryToken = values.FirstOrDefault();
if (!String.IsNullOrWhiteSpace(queryToken))
{
context.Token = queryToken;
return Task.CompletedTask;
}
var cookieToken = context.Request.Cookies["access_token"];
if (!String.IsNullOrWhiteSpace(cookieToken))
{
context.Token = cookieToken;
return Task.CompletedTask;
}
return Task.CompletedTask;
}
};
// OPTION 1: use `Invio.Extensions.Authentication.JwtBearer`
options.AddQueryStringAuthentication();
//options.AddQueryStringAuthentication();
//).AddJwtBearerQueryStringAuthentication(
// (JwtBearerQueryStringOptions options) =>
// {
// options.QueryStringParameterName = "access_token";
// options.QueryStringBehavior = QueryStringBehaviors.Redact;
// };
// OPTION 2: do it manually
#region

View File

@ -333,7 +333,19 @@ namespace IRaCIS.Core.Application.Services
.WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name))
.WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId);
return await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
var reuslt = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc);
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id))
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.CountAsync();
var needSignSystemDocCount = await _systemDocumentRepository
.Where(t => t.IsDeleted == false && !t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.CountAsync();
result.OtherData = new { NeedSignCount = needSignTrialDocCount + needSignSystemDocCount, NeedSignTrialDocCount = needSignTrialDocCount, NeedSignSystemDocCount = needSignSystemDocCount };
}