Added authenication/authorization. Refactored api startup.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using JSMR.Application.Users;
|
||||
using JSMR.Domain.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace JSMR.Infrastructure.Data.Repositories.Users;
|
||||
|
||||
public class UserRepository(AppDbContext db) : IUserRepository
|
||||
{
|
||||
public async Task<User?> FindByUsernameAsync(string username)
|
||||
{
|
||||
return await db.Users
|
||||
.FirstOrDefaultAsync(u => u.Username == username);
|
||||
}
|
||||
|
||||
public bool VerifyPassword(User user, string password)
|
||||
{
|
||||
// Using BCrypt (recommended)
|
||||
return BCrypt.Net.BCrypt.Verify(password, user.PasswordHash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user