2024-12-26 13:38:43 +03:00
|
|
|
|
using Mirea.Api.Security.Common.Domain;
|
|
|
|
|
using Mirea.Api.Security.Common.Interfaces;
|
2024-11-04 02:39:10 +03:00
|
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
2024-12-26 13:38:43 +03:00
|
|
|
|
namespace Mirea.Api.Security.Common.OAuth2.UserInfo;
|
2024-11-04 02:39:10 +03:00
|
|
|
|
|
|
|
|
|
internal class GoogleUserInfo : IUserInfo
|
|
|
|
|
{
|
|
|
|
|
[JsonPropertyName("id")]
|
|
|
|
|
public required string Id { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("email")]
|
|
|
|
|
public required string Email { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("given_name")]
|
|
|
|
|
public required string GivenName { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("family_name")]
|
|
|
|
|
public required string FamilyName { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("name")]
|
|
|
|
|
public required string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("picture")]
|
|
|
|
|
public required string Picture { get; set; }
|
|
|
|
|
|
|
|
|
|
[JsonPropertyName("verified_email")]
|
|
|
|
|
public bool? VerifiedEmail { get; set; }
|
|
|
|
|
|
|
|
|
|
public OAuthUser MapToInternalUser() =>
|
|
|
|
|
new()
|
|
|
|
|
{
|
|
|
|
|
Id = Id,
|
|
|
|
|
Email = VerifiedEmail.HasValue && VerifiedEmail.Value ? Email : null,
|
|
|
|
|
FirstName = GivenName,
|
|
|
|
|
LastName = FamilyName,
|
|
|
|
|
IconUri = Picture
|
|
|
|
|
};
|
|
|
|
|
}
|