using System.Security.Claims; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging; using MediatR; using CellularManagement.Application.Common.Extensions; using CellularManagement.Domain.Entities; using CellularManagement.Domain.Repositories; using CellularManagement.Domain.Services; using System.Collections.Generic; using System.Threading.Tasks; using System.Threading; using System.Linq; using System; using CellularManagement.Domain.Common; using Microsoft.AspNetCore.Http; using UAParser; using Microsoft.EntityFrameworkCore; using CellularManagement.Application.Features.Auth.Models; using CellularManagement.Domain.Repositories.Identity; using CellularManagement.Domain.Repositories.Base; namespace CellularManagement.Application.Features.Auth.Commands.AuthenticateUser; /// /// 账号登录命令处理器 /// public sealed class AuthenticateUserCommandHandler : BaseLoginCommandHandler { /// /// 初始化处理器 /// public AuthenticateUserCommandHandler( UserManager userManager, IJwtProvider jwtProvider, ILogger logger, IUserRoleRepository userRoleRepository, IRolePermissionRepository rolePermissionRepository, IUnitOfWork unitOfWork, ILoginLogRepository loginLogRepository, IHttpContextAccessor httpContextAccessor) : base(userManager, jwtProvider, logger, userRoleRepository, rolePermissionRepository, unitOfWork, loginLogRepository, httpContextAccessor) { } /// /// 处理认证请求 /// public override Task> Handle( AuthenticateUserCommand request, CancellationToken cancellationToken) { return HandleLoginAsync(request, cancellationToken); } /// /// 查找用户 /// protected override Task FindUserAsync(AuthenticateUserCommand request) { return _userManager.FindByNameAsync(request.UserName); } /// /// 获取用户标识 /// protected override string GetUserIdentifier(AuthenticateUserCommand request) { return request.UserName; } /// /// 获取密码 /// protected override string GetPassword(AuthenticateUserCommand request) { return request.Password; } }