mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
auth updates
This commit is contained in:
@@ -7,22 +7,7 @@ namespace ServiceCore.Services
|
||||
{
|
||||
public async Task<UserAccount> RegisterAsync(UserAccount userAccount, string password)
|
||||
{
|
||||
if (userAccount.UserAccountId == Guid.Empty)
|
||||
{
|
||||
userAccount.UserAccountId = Guid.NewGuid();
|
||||
}
|
||||
|
||||
await userRepo.AddAsync(userAccount);
|
||||
|
||||
var credential = new UserCredential
|
||||
{
|
||||
UserAccountId = userAccount.UserAccountId,
|
||||
Hash = PasswordHasher.Hash(password)
|
||||
};
|
||||
|
||||
await credRepo.RotateCredentialAsync(userAccount.UserAccountId, credential);
|
||||
|
||||
return userAccount;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<UserAccount?> LoginAsync(string usernameOrEmail, string password)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
using DataAccessLayer.Entities;
|
||||
|
||||
namespace ServiceCore.Services
|
||||
@@ -9,8 +7,6 @@ namespace ServiceCore.Services
|
||||
Task<IEnumerable<UserAccount>> GetAllAsync(int? limit = null, int? offset = null);
|
||||
Task<UserAccount?> GetByIdAsync(Guid id);
|
||||
|
||||
Task AddAsync(UserAccount userAccount);
|
||||
|
||||
Task UpdateAsync(UserAccount userAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ using JwtRegisteredClaimNames = System.IdentityModel.Tokens.Jwt.JwtRegisteredCla
|
||||
namespace ServiceCore.Services;
|
||||
public class JwtService(IConfiguration config) : IJwtService
|
||||
{
|
||||
private readonly string? _secret = config["Jwt:Secret"];
|
||||
|
||||
// private readonly string? _secret = config["Jwt:Secret"];
|
||||
private readonly string? _secret = "128490218jfklsdajfdsa90f8sd0fid0safasr31jl2k1j4AFSDR!@#$fdsafjdslajfl";
|
||||
public string GenerateJwt(Guid userId, string username, DateTime expiry)
|
||||
{
|
||||
var handler = new JsonWebTokenHandler();
|
||||
|
||||
@@ -14,12 +14,7 @@ namespace ServiceCore.Services
|
||||
{
|
||||
return await repository.GetByIdAsync(id);
|
||||
}
|
||||
|
||||
public async Task AddAsync(UserAccount userAccount)
|
||||
{
|
||||
await repository.AddAsync(userAccount);
|
||||
}
|
||||
|
||||
|
||||
public async Task UpdateAsync(UserAccount userAccount)
|
||||
{
|
||||
await repository.UpdateAsync(userAccount);
|
||||
|
||||
Reference in New Issue
Block a user