/
softailor
/
gridient
Обзор
Документация
Войти
/
softailor
/
gridient
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/Gridient.Infrastructure.Authentication.Local/Controllers/AuthController.cs
48 строк
2 KB
Jenkins
Auto add
18 фев 2026, 10:19
18 фев 2026, 10:19
1e6c4f8
Код
Авторство
О чём код?
using Gridient.Infrastructure.Authentication.Local.Features.Auth.Commands; using Gridient.Infrastructure.Authentication.Local.Models; using MediatR; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Gridient.Infrastructure.Authentication.Local.Controllers { [ApiController] [Route("api/[controller]")] public class AuthController(IMediator mediator) : ControllerBase { private readonly IMediator _mediator = mediator; [HttpPost("login")] [AllowAnonymous] public async Task<IActionResult> Login([FromBody] AuthModel model, CancellationToken cancellationToken) { var command = new LoginCommand(model.Username, model.Password); var result = await _mediator.Send(command, cancellationToken); if (result == null) return Unauthorized(); return Ok(result); } [HttpPost("refresh")] [AllowAnonymous] public async Task<IActionResult> Refresh([FromBody] RefreshModel model, CancellationToken cancellationToken) { var command = new RefreshTokenCommand(model.RefreshToken); var result = await _mediator.Send(command, cancellationToken); if (result == null) return Unauthorized(); return Ok(result); } [Authorize] [HttpPost("logout")] public async Task<IActionResult> Logout([FromBody] RefreshModel model, CancellationToken cancellationToken) { var command = new LogoutCommand(model.RefreshToken); await _mediator.Send(command, cancellationToken); return Ok("Выход успешно произведён"); } } }