namespace MiaoYu.Api.Admin.Controllers.Indentity; /// /// 认证服务 /// public class AccountController : IndentityControllerBase { private const string tokenType = $"{JwtBearerDefaults.AuthenticationScheme} "; private readonly JwtTokenService _jwtTokenService; private readonly IConfiguration _configuration; private readonly IAccountService _accountService; /// /// /// /// /// /// public AccountController(JwtTokenService jwtTokenService, IConfiguration configuration, IAccountService accountService) { _jwtTokenService = jwtTokenService; _configuration = configuration; _accountService = accountService; } /// /// 检查账户 登录信息 并返回 token /// /// /// [HttpPost] public async Task LoginAsync([FromBody] AuthUserFormDto authUserDto) { var id = await _accountService.LoginAsync(authUserDto); var tokenString = _jwtTokenService.CreateTokenByAccountId(id); return new { token = tokenType + tokenString, tokenType }; } /// /// /// /// [HttpGet("{key}")] public object TestConfig([FromRoute] string key) { return new { conf = _configuration[key], key }; } }