Invalidate JWTs on profile changes

This commit is contained in:
Holden
2026-06-28 12:46:12 -05:00
parent fefa01cf3f
commit e194bbf9c4
15 changed files with 395 additions and 47 deletions

View File

@@ -30,6 +30,15 @@ public class ProfileService(
: mapper.Map<ProfileDTO>(profile);
}
public async Task<IReadOnlyList<ProfileDTO>> GetProfilesAsync(
List<Guid> profileIds,
CancellationToken ct = default)
{
var profiles = await profileRepository.GetByIdsAsync(profileIds, ct);
return mapper.Map<List<ProfileDTO>>(profiles);
}
public async Task<AvatarDTO?> GetAvatarAsync(Guid profileId, CancellationToken ct = default)
{
var avatar = await profileRepository.GetAvatarByProfileIdAsync(profileId, ct);
@@ -86,13 +95,15 @@ public class ProfileService(
return true;
}
public async Task<IReadOnlyList<ProfileDTO>> GetProfilesAsync(
List<Guid> profileIds,
CancellationToken ct = default)
public async Task IncrementTokenVersion(Guid profileId, CancellationToken ct = default)
{
var profiles = await profileRepository.GetByIdsAsync(profileIds, ct);
return mapper.Map<List<ProfileDTO>>(profiles);
var profile = await profileRepository.GetByIdWithSettingsAsync(profileId, ct);
if (profile is null)
return;
profile.IncrementTokenVersion();
await profileRepository.SaveChangesAsync(ct);
}
public async Task<LoginProfileResult> LoginAsync(
@@ -146,7 +157,7 @@ public class ProfileService(
return LoginProfileResult.Fail("Platform Auth Failed: Invalid authentication");
if (profile.IsBanned)
return LoginProfileResult.Fail("Profile is banned");
return LoginProfileResult.Fail("TenWholeYears requires you to take a shower in order to continue playing.");
profile.RecordSuccessfulLogin(command.DeviceId, auth.Name);