chore: init commit from GitHub
This commit is contained in:
33
SWAD.API/Services/MusicAPI/Auth/AbstractAuthService.cs
Normal file
33
SWAD.API/Services/MusicAPI/Auth/AbstractAuthService.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using SWAD.API.Consts.Enums;
|
||||
using SWAD.API.Models.Config.ApiServices.Structure;
|
||||
|
||||
namespace SWAD.API.Services.MusicAPI.Auth;
|
||||
|
||||
public abstract class AbstractAuthService
|
||||
{
|
||||
public MusicService ServiceType { get; protected init; }
|
||||
|
||||
// ReSharper disable once NullableWarningSuppressionIsUsed
|
||||
protected ApiServiceData Data { get; init; } = null!;
|
||||
public abstract Task<IAuthResponse?> GetToken();
|
||||
|
||||
/// <summary>
|
||||
/// Get all implemented Auth Services
|
||||
/// </summary>
|
||||
/// <returns>API Services types</returns>
|
||||
public static IEnumerable<Type> GetAllImplementations()
|
||||
{
|
||||
var type = typeof(AbstractAuthService);
|
||||
var types = AppDomain.CurrentDomain.GetAssemblies()
|
||||
.SelectMany(s => s.GetTypes())
|
||||
.Where(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
|
||||
return types;
|
||||
}
|
||||
}
|
||||
|
||||
public interface IAuthResponse
|
||||
{
|
||||
public string Token { get; set; }
|
||||
public int? ExpireTime { get; set; }
|
||||
public DateTime? ExpireAt { get; }
|
||||
}
|
||||
Reference in New Issue
Block a user