策略授权

Uat_Study
hang 2022-05-24 14:04:43 +08:00
parent 5348daad3f
commit 5ef1c90289
2 changed files with 25 additions and 20 deletions

View File

@ -24,6 +24,11 @@ namespace IRaCIS.Core.API
});
options.AddPolicy("PmAndApmPolicy", policyBuilder =>
{
policyBuilder.RequireClaim("userTypeEnumInt", ((int)UserTypeEnum.ProjectManager).ToString(), ((int)UserTypeEnum.APM).ToString());
});
});

View File

@ -143,10 +143,6 @@ namespace IRaCIS.Core.Application.Image.QA
/// <summary>
/// 关闭质疑,什么情况下允许?
/// </summary>
/// <param name="qcChallengeId"></param>
/// <param name="subjectVisitId"></param>
/// <param name="closeEnum"></param>
/// <param name="closeReason"></param>
/// <returns></returns>
[HttpPut]
[TypeFilter(typeof(TrialResourceFilter))]
@ -337,12 +333,13 @@ namespace IRaCIS.Core.Application.Image.QA
/// <returns></returns>
[HttpPut("{trialId:guid}")]
[TypeFilter(typeof(TrialResourceFilter))]
[Authorize(Policy = "PmAndApmPolicy")]
public async Task<IResponseOutput> SetCheckPass(SetCheckPassDt data)
{
if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
{
ResponseOutput.NotOk("您不是PM/APM,不允许设置一致性核查通过");
}
//if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
//{
// ResponseOutput.NotOk("您不是PM/APM,不允许设置一致性核查通过");
//}
var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == data.Id)).IfNullThrowException();
@ -415,12 +412,13 @@ namespace IRaCIS.Core.Application.Image.QA
}
[HttpPut("{trialId:guid}/{subjectVisitId:guid}")]
[Authorize(Policy = "PmAndApmPolicy")]
public async Task<IResponseOutput> RejectCheckBack(Guid subjectVisitId)
{
if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
{
return ResponseOutput.NotOk(" 只有PM/APM具有操作权限!");
}
//if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
//{
// return ResponseOutput.NotOk(" 只有PM/APM具有操作权限!");
//}
var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException();
@ -446,13 +444,14 @@ namespace IRaCIS.Core.Application.Image.QA
/// <returns></returns>
[HttpPut("{trialId:guid}/{subjectVisitId:guid}")]
[TypeFilter(typeof(TrialResourceFilter))]
[Authorize(Policy = "PmAndApmPolicy")]
[UnitOfWork]
public async Task<IResponseOutput> CheckBack(Guid subjectVisitId)
{
if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
{
return ResponseOutput.NotOk("只有PM/APM具有操作权限!");
}
//if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
//{
// return ResponseOutput.NotOk("只有PM/APM具有操作权限!");
//}
var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException();
@ -519,12 +518,13 @@ namespace IRaCIS.Core.Application.Image.QA
/// <returns></returns>
[HttpPost("{trialId:guid}")]
[TypeFilter(typeof(TrialResourceFilter))]
[Authorize(Policy = "PmAndApmPolicy")]
public async Task<IResponseOutput> UploadVisitCheckExcel(IFormFile file, Guid trialId)
{
if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
{
return ResponseOutput.NotOk("只有PM/APM具有操作权限!");
}
//if (_userInfo.UserTypeEnumInt != (int)UserTypeEnum.ProjectManager && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.APM)
//{
// return ResponseOutput.NotOk("只有PM/APM具有操作权限!");
//}
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;