ソースを参照

AuthResponse : userType

zinab_elgendy 8 ヶ月 前
コミット
299b921cfb
共有2 個のファイルを変更した3 個の追加2 個の削除を含む
  1. 1 1
      MTWorkHR.Application/Dtos/Identity/AuthResponse.cs
  2. 2 1
      MTWorkHR.Application/Services/Auth/AuthService.cs

+ 1 - 1
MTWorkHR.Application/Dtos/Identity/AuthResponse.cs

@@ -12,7 +12,7 @@ namespace MTWorkHR.Application.Models
         public string Id { get; set; }
         public string UserName { get; set; }
         public string Email { get; set; }
-        public UserTypeEnum UserTypeId { get; set; }
+        public int UserTypeId { get; set; }
         public string Token{ get; set; }
         public DateTime Expiration { get; set; }
     }

+ 2 - 1
MTWorkHR.Application/Services/Auth/AuthService.cs

@@ -34,7 +34,7 @@ namespace MTWorkHR.Identity.Services
             var result = await _signInManager.CheckPasswordSignInAsync(user, request.Password, false);
             if(!result.Succeeded)
             {
-                throw new BadRequest($"Credentials for '{request.Email} are not valid'.");
+                throw new AppException($"Credentials for '{request.Email} are not valid'.");
             }
             JwtSecurityToken jwtToken = await GenerateToken(user);
             var response = new AuthResponse
@@ -42,6 +42,7 @@ namespace MTWorkHR.Identity.Services
                 Id = user.Id,
                 Email = user.Email,
                 UserName = user.UserName,
+                UserTypeId = user.UserType,
                 Token = new JwtSecurityTokenHandler().WriteToken( jwtToken),
                 Expiration = jwtToken.ValidTo
             };