session
This commit is contained in:
parent
baea64229b
commit
0dc41337da
36 changed files with 324 additions and 95 deletions
23
Femto.Modules.Auth/Contracts/AuthenticationService.cs
Normal file
23
Femto.Modules.Auth/Contracts/AuthenticationService.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using Femto.Modules.Auth.Data;
|
||||
using Femto.Modules.Auth.Models;
|
||||
|
||||
namespace Femto.Modules.Auth.Contracts;
|
||||
|
||||
internal class AuthenticationService(AuthContext 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);
|
7
Femto.Modules.Auth/Contracts/IAuthenticationService.cs
Normal file
7
Femto.Modules.Auth/Contracts/IAuthenticationService.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace Femto.Modules.Auth.Contracts;
|
||||
|
||||
public interface IAuthenticationService
|
||||
{
|
||||
public Task<UserInfo?> Register(string username, string password);
|
||||
public Task<UserInfo?> Authenticate(string username, string password);
|
||||
}
|
3
Femto.Modules.Auth/Contracts/UserInfo.cs
Normal file
3
Femto.Modules.Auth/Contracts/UserInfo.cs
Normal file
|
@ -0,0 +1,3 @@
|
|||
namespace Femto.Modules.Auth.Contracts;
|
||||
|
||||
public record UserInfo(Guid UserId, string Username);
|
Loading…
Add table
Add a link
Reference in a new issue