Files
pas/Api/Models/User.cs
Marek Lesko f34d523413 feat: Implement OAuth2 authentication with Microsoft, Google, and PocketId
- Added JWT configuration to appsettings.json for secure token handling.
- Updated config.json to include OAuth provider details for Microsoft, Google, and PocketId.
- Added Microsoft icon SVG for UI representation.
- Refactored app.config.ts to use a custom AuthInterceptor for managing access tokens.
- Enhanced auth route guard to handle asynchronous authentication checks.
- Created new auth models for structured request and response handling.
- Developed a callback component to manage user login states and transitions.
- Updated side-login component to support multiple OAuth providers with loading states.
- Implemented authentication service methods for handling OAuth login flows and token management.
- Added error handling and user feedback for authentication processes.
2025-11-07 19:23:21 +00:00

72 lines
1.9 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Api.Models
{
public class User
{
[Key]
public int Id { get; set; }
[Required]
[StringLength(255)]
public string Email { get; set; } = string.Empty;
[StringLength(255)]
public string? FirstName { get; set; }
[StringLength(255)]
public string? LastName { get; set; }
[StringLength(500)]
public string? ProfilePictureUrl { get; set; }
[Required]
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? LastLoginAt { get; set; }
public bool IsActive { get; set; } = true;
// Navigation property for OAuth providers
public virtual ICollection<UserOAuthProvider> OAuthProviders { get; set; } = new List<UserOAuthProvider>();
}
public class UserOAuthProvider
{
[Key]
public int Id { get; set; }
[Required]
public int UserId { get; set; }
[Required]
public OAuthProvider Provider { get; set; }
[Required]
[StringLength(255)]
public string ProviderId { get; set; } = string.Empty;
[StringLength(255)]
public string? ProviderEmail { get; set; }
[StringLength(255)]
public string? ProviderName { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? LastUsedAt { get; set; }
// Navigation property
[ForeignKey("UserId")]
public virtual User User { get; set; } = null!;
}
public enum OAuthProvider
{
Microsoft = 1,
Google = 2,
PocketId = 3
// Add more providers as needed
}
}