fix: improve auth flow and verification
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user