add 验证码demo示例

This commit is contained in:
luoyunchong
2020-09-04 01:37:34 +08:00
parent 35fa68cffc
commit 8a4066a40e
6 changed files with 80 additions and 14 deletions

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NCaptcha.Abstractions;
using NCaptcha.AspNetCore.Extensions;
namespace OAuth2Integration.ResourceServer.Controllers
{
[Route("captcha")]
public class CaptchaController : Controller
{
private readonly ICaptchaGenerator _captchaGenerator;
public CaptchaController(ICaptchaGenerator captchaGenerator)
{
_captchaGenerator = captchaGenerator;
}
[Produces("image/gif", Type = typeof(FileContentResult))]
[HttpGet]
public async Task<IActionResult> OnGetCaptchaAsync() => await _captchaGenerator.GetCaptchaFileResultAsync();
}
}