mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 03:56:30 +00:00
26 lines
738 B
C#
26 lines
738 B
C#
using Azaion.CommonSecurity.DTO;
|
|
using Azaion.CommonSecurity.DTO.Commands;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace Azaion.CommonSecurity.Services;
|
|
|
|
public interface IAuthProvider
|
|
{
|
|
void Login(ApiCredentials credentials);
|
|
User CurrentUser { get; }
|
|
}
|
|
|
|
public class AuthProvider(IInferenceClient inferenceClient) : IAuthProvider
|
|
{
|
|
public User CurrentUser { get; private set; } = null!;
|
|
|
|
public void Login(ApiCredentials credentials)
|
|
{
|
|
inferenceClient.Send(RemoteCommand.Create(CommandType.Login, credentials));
|
|
var user = inferenceClient.Get<User>();
|
|
if (user == null)
|
|
throw new Exception("Can't get user from Auth provider");
|
|
|
|
CurrentUser = user;
|
|
}
|
|
} |