fix: скрыл инфу о активности ака и перестал выдавать рефреши если ак не активен
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user