Add JWT authentication.
Add: JWT authentication in Web API. Related configuration and services are added.
This commit is contained in:
@ -7,6 +7,7 @@ public interface IUserService
|
||||
{
|
||||
IEnumerable<User> GetUsers();
|
||||
User? GetUserById(string id);
|
||||
User? GetUserByUsername(string username);
|
||||
}
|
||||
|
||||
public class UserService(AppDbContext dbContext) : IUserService
|
||||
@ -18,6 +19,11 @@ public class UserService(AppDbContext dbContext) : IUserService
|
||||
return _dbContext.Users.FirstOrDefault(u => u.Id == id);
|
||||
}
|
||||
|
||||
public User? GetUserByUsername(string username)
|
||||
{
|
||||
return _dbContext.Users.FirstOrDefault(u => u.UserName == username);
|
||||
}
|
||||
|
||||
public IEnumerable<User> GetUsers()
|
||||
{
|
||||
return _dbContext.Users.AsEnumerable();
|
||||
|
Reference in New Issue
Block a user