Add Meta authentication secret and SHA256 hashing
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using AutoMapper;
|
||||
using RecNet.Application.Common.Interfaces;
|
||||
using RecNet.Application.Common.Security;
|
||||
using RecNet.Domain.Common;
|
||||
using RecNet.Domain.GameVersions;
|
||||
using RecNet.Domain.Profiles;
|
||||
using ProfileEntity = RecNet.Domain.Profiles.Profile;
|
||||
@@ -51,7 +53,7 @@ public class ProfileService(
|
||||
);
|
||||
|
||||
await profileRepository.SaveChangesAsync(ct);
|
||||
|
||||
|
||||
return mapper.Map<AvatarDTO>(profile.Avatar);
|
||||
}
|
||||
|
||||
@@ -60,13 +62,13 @@ public class ProfileService(
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var settings = await profileRepository.GetSettingsByProfileIdAsync(profileId, ct);
|
||||
|
||||
|
||||
return mapper.Map<List<PlayerSettingDTO>>(settings);
|
||||
}
|
||||
|
||||
public async Task<bool> UpdatePlayerSettingAsync(
|
||||
Guid profileId,
|
||||
UpdatePlayerSettingCommand command,
|
||||
Guid profileId,
|
||||
UpdatePlayerSettingCommand command,
|
||||
CancellationToken ct = default)
|
||||
{
|
||||
var profile = await profileRepository.GetByIdWithSettingsAsync(profileId, ct);
|
||||
@@ -130,9 +132,15 @@ public class ProfileService(
|
||||
command.PlatformType,
|
||||
command.PlatformId);
|
||||
|
||||
if (command.PlatformType == PlatformType.Meta)
|
||||
profile.SetMetaAuthenticationSecret(Hashing.ComputeSha256(command.PlatformAuthentication));
|
||||
|
||||
await profileRepository.AddAsync(profile, ct);
|
||||
}
|
||||
|
||||
if (command.PlatformType == PlatformType.Meta && !Hashing.VerifySha256(command.PlatformAuthentication, profile.MetaAuthenticationSecret))
|
||||
return LoginProfileResult.Fail("Platform Auth Failed: Invalid authentication");
|
||||
|
||||
if (profile.IsBanned)
|
||||
return LoginProfileResult.Fail("Profile is banned");
|
||||
|
||||
@@ -148,4 +156,4 @@ public class ProfileService(
|
||||
expiresIn: token.ExpiresIn
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user