added findByUserNameAsync to the interface and service
This commit is contained in:
@@ -9,6 +9,7 @@ public interface IIdentityService
|
|||||||
Task<UserModel?> FindUserByIdAsync(string id);
|
Task<UserModel?> FindUserByIdAsync(string id);
|
||||||
Task<UserModel?> GetCurrentUserAsync();
|
Task<UserModel?> GetCurrentUserAsync();
|
||||||
Task<UserModel?> FindUserByEmailAsync(string id);
|
Task<UserModel?> FindUserByEmailAsync(string id);
|
||||||
|
Task<UserModel?> GetUserByUserNameAsync(string userName);
|
||||||
Task<bool> IsInRoleAsync(string userId, string role);
|
Task<bool> IsInRoleAsync(string userId, string role);
|
||||||
Task<bool> AuthorizeAsync(string userId, string policyName);
|
Task<bool> AuthorizeAsync(string userId, string policyName);
|
||||||
Task<Result> AddRoleAsync(string userId, string role);
|
Task<Result> AddRoleAsync(string userId, string role);
|
||||||
|
|||||||
@@ -21,6 +21,24 @@ public class IdentityService(
|
|||||||
|
|
||||||
return user?.UserName;
|
return user?.UserName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<UserModel?> GetUserByUserNameAsync(string userName)
|
||||||
|
{
|
||||||
|
var response = await userManager.FindByNameAsync(userName);
|
||||||
|
|
||||||
|
if (response == null) return null;
|
||||||
|
|
||||||
|
var userModel = new UserModel()
|
||||||
|
{
|
||||||
|
Id = response.Id,
|
||||||
|
UserName = response.UserName,
|
||||||
|
FirstName = response.FirstName,
|
||||||
|
LastName = response.LastName,
|
||||||
|
Email = response.Email,
|
||||||
|
};
|
||||||
|
|
||||||
|
return userModel;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<(Result Result, string UserId)> CreateUserAsync(string userName, string password)
|
public async Task<(Result Result, string UserId)> CreateUserAsync(string userName, string password)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user