fix: improve auth flow and verification

This commit is contained in:
2026-09-03 07:49:30 +03:30
parent 6297df7dfd
commit e7a1f79806
3 changed files with 68 additions and 6 deletions

View File

@@ -52,5 +52,23 @@ public class AuthController : ControllerBase
var canResend = await authService.CanResendCodeAsync(mobile, cancellationToken);
return Ok(new { canResend });
}
[HttpGet("me")]
public async Task<ActionResult<UserDto>> Me(CancellationToken cancellationToken)
{
var authHeader = Request.Headers.Authorization.ToString();
var token = authHeader.StartsWith("Bearer ", StringComparison.OrdinalIgnoreCase)
? authHeader.Substring("Bearer ".Length).Trim()
: null;
if (string.IsNullOrEmpty(token))
return Unauthorized();
var user = await authService.GetUserByTokenAsync(token, cancellationToken);
if (user == null)
return Unauthorized();
return Ok(user);
}
}