创建签名验证自定义中间件 ,优化代码结构

This commit is contained in:
2021-02-26 16:40:51 +08:00
parent 7c3ce74a3b
commit d6617f47c0
8 changed files with 128 additions and 54 deletions

View File

@@ -9,6 +9,7 @@ using System.IO;
using QRCodeService.Application.Queries;
using QRCodeService.Models;
using QRCodeService.Options;
using QRCodeService.Infrastructure.Middlewares;
namespace QRCodeService.Controllers
{
@@ -25,20 +26,11 @@ namespace QRCodeService.Controllers
this.appQueries = appQueries;
this.option = option;
}
[CheckSign(typeof(GetQRCodeModel))]
[Route("qrcode")]
[HttpPost]
public async Task<IActionResult> GetImage(GetQRCodeModel input)
{
var app = await appQueries.GetAppAsync(input.AppId);
if (app == null)
{
return BadRequest();
}
if (!await input.CheckValidAsync(app.Appkey))
{
return BadRequest();
}
var link = await linkQueries.GetLinkAsync(input.ShortCode);
if (link.AppId != input.AppId)
{