fix: скрыл инфу о активности ака и перестал выдавать рефреши если ак не активен

This commit is contained in:
2026-05-18 03:15:45 +03:00
parent 934682f035
commit 6eeacd80cc
11 changed files with 206 additions and 8 deletions
@@ -186,6 +186,13 @@ public class AuthService : IAuthService
if (token == null || !token.IsActive)
throw new ForbiddenException("Неверный или просроченный токен обновления.");
if (!token.User.IsActive)
{
token.RevokedAt = DateTime.UtcNow;
await _db.SaveChangesAsync();
throw new ForbiddenException("Аккаунт деактивирован.");
}
// Revoke old token
token.RevokedAt = DateTime.UtcNow;
@@ -215,13 +222,16 @@ public class AuthService : IAuthService
}
}
public async Task<UserDto> GetCurrentUserAsync(int userId)
public async Task<CurrentUserDto> GetCurrentUserAsync(int userId)
{
var user = await _db.Users
.Include(u => u.Roles)
.FirstOrDefaultAsync(u => u.Id == userId)
?? throw new NotFoundException("User", userId);
return user.ToDto(await _gamification.CalculateLevelAsync(user.Xp));
if (!user.IsActive)
throw new ForbiddenException("Аккаунт деактивирован.");
return user.ToCurrentUserDto(await _gamification.CalculateLevelAsync(user.Xp));
}
private async Task TrySendLoginNotificationAsync(User user, string? ipAddress)