♻️ Moving to MagicOnion
This commit is contained in:
		
							
								
								
									
										30
									
								
								DysonNetwork.Shared/Models/MagicSpell.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								DysonNetwork.Shared/Models/MagicSpell.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,30 @@ | ||||
| using System.ComponentModel.DataAnnotations; | ||||
| using System.ComponentModel.DataAnnotations.Schema; | ||||
| using System.Text.Json.Serialization; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using NodaTime; | ||||
|  | ||||
| namespace DysonNetwork.Shared.Models; | ||||
|  | ||||
| public enum MagicSpellType | ||||
| { | ||||
|     AccountActivation, | ||||
|     AccountDeactivation, | ||||
|     AccountRemoval, | ||||
|     AuthPasswordReset, | ||||
|     ContactVerification, | ||||
| } | ||||
|  | ||||
| [Index(nameof(Spell), IsUnique = true)] | ||||
| public class MagicSpell : ModelBase | ||||
| { | ||||
|     public Guid Id { get; set; } = Guid.NewGuid(); | ||||
|     [JsonIgnore] [MaxLength(1024)] public string Spell { get; set; } = null!; | ||||
|     public MagicSpellType Type { get; set; } | ||||
|     public Instant? ExpiresAt { get; set; } | ||||
|     public Instant? AffectedAt { get; set; } | ||||
|     [Column(TypeName = "jsonb")] public Dictionary<string, object> Meta { get; set; } = new(); | ||||
|  | ||||
|     public Guid? AccountId { get; set; } | ||||
|     public Shared.Models.Account? Account { get; set; } | ||||
| } | ||||
							
								
								
									
										49
									
								
								DysonNetwork.Shared/Models/OidcUserInfo.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								DysonNetwork.Shared/Models/OidcUserInfo.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| namespace DysonNetwork.Shared.Models; | ||||
|  | ||||
| /// <summary> | ||||
| /// Represents the user information from an OIDC provider | ||||
| /// </summary> | ||||
| public class OidcUserInfo | ||||
| { | ||||
|     public string? UserId { get; set; } | ||||
|     public string? Email { get; set; } | ||||
|     public bool EmailVerified { get; set; } | ||||
|     public string FirstName { get; set; } = ""; | ||||
|     public string LastName { get; set; } = ""; | ||||
|     public string DisplayName { get; set; } = ""; | ||||
|     public string PreferredUsername { get; set; } = ""; | ||||
|     public string? ProfilePictureUrl { get; set; } | ||||
|     public string Provider { get; set; } = ""; | ||||
|     public string? RefreshToken { get; set; } | ||||
|     public string? AccessToken { get; set; } | ||||
|  | ||||
|     public Dictionary<string, object> ToMetadata() | ||||
|     { | ||||
|         var metadata = new Dictionary<string, object>(); | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(UserId)) | ||||
|             metadata["user_id"] = UserId; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(Email)) | ||||
|             metadata["email"] = Email; | ||||
|  | ||||
|         metadata["email_verified"] = EmailVerified; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(FirstName)) | ||||
|             metadata["first_name"] = FirstName; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(LastName)) | ||||
|             metadata["last_name"] = LastName; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(DisplayName)) | ||||
|             metadata["display_name"] = DisplayName; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(PreferredUsername)) | ||||
|             metadata["preferred_username"] = PreferredUsername; | ||||
|  | ||||
|         if (!string.IsNullOrWhiteSpace(ProfilePictureUrl)) | ||||
|             metadata["profile_picture_url"] = ProfilePictureUrl; | ||||
|  | ||||
|         return metadata; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user