Преглед на файлове

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
             };