femto-backend/Femto.Modules.Authentication/Contracts/AuthenticationService.cs

23 lines
748 B
C#

using Femto.Modules.Authentication.Data;
using Femto.Modules.Authentication.Models;
namespace Femto.Modules.Authentication.Contracts;
internal class AuthenticationService(AuthenticationContext context) : IAuthenticationService
{
public async Task<UserInfo> Register(string username, string password)
{
var user = new UserIdentity(username).WithPassword(password);
await context.AddAsync(user);
await context.SaveChangesAsync();
return new(user.Id, user.Username);
}
public async Task<UserInfo> Authenticate(string username, string password)
{
throw new NotImplementedException();
}
}
public class AuthenticationError(string message, Exception inner) : Exception(message, inner);