feat: add authorize in OAuth
This commit is contained in:
41
Security/Common/Domain/OAuth2/UserInfo/YandexUserInfo.cs
Normal file
41
Security/Common/Domain/OAuth2/UserInfo/YandexUserInfo.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Mirea.Api.Security.Common.Interfaces;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Mirea.Api.Security.Common.Domain.OAuth2.UserInfo;
|
||||
|
||||
internal class YandexUserInfo : IUserInfo
|
||||
{
|
||||
[JsonPropertyName("id")]
|
||||
public required string Id { get; set; }
|
||||
|
||||
[JsonPropertyName("login")]
|
||||
public required string Login { get; set; }
|
||||
|
||||
[JsonPropertyName("default_email")]
|
||||
public required string DefaultEmail { get; set; }
|
||||
|
||||
[JsonPropertyName("first_name")]
|
||||
public string? FirstName { get; set; }
|
||||
|
||||
[JsonPropertyName("last_name")]
|
||||
public string? LastName { get; set; }
|
||||
|
||||
|
||||
[JsonPropertyName("is_avatar_empty")]
|
||||
public bool IsAvatarEmpty { get; set; }
|
||||
|
||||
[JsonPropertyName("default_avatar_id")]
|
||||
public string? DefaultAvatarId { get; set; }
|
||||
|
||||
public OAuthUser MapToInternalUser() =>
|
||||
new()
|
||||
{
|
||||
Id = Id,
|
||||
Email = DefaultEmail,
|
||||
FirstName = FirstName,
|
||||
LastName = LastName,
|
||||
IconUri =
|
||||
IsAvatarEmpty ? null : $"https://avatars.yandex.net/get-yapic/{DefaultAvatarId}/islands-retina-50",
|
||||
Username = Login
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user