Invalidate JWTs on profile changes
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user