From 8325752355667c9bdd681ca7cac5d6deb8eab616 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Tue, 22 Jul 2025 11:09:42 +0330 Subject: [PATCH] add userType to login data --- ServiceHost/Areas/Admin/Controllers/LoginController.cs | 8 +++++--- ServiceHost/Areas/Client/Controllers/LoginController.cs | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ServiceHost/Areas/Admin/Controllers/LoginController.cs b/ServiceHost/Areas/Admin/Controllers/LoginController.cs index 9ef8f89f..9c5b4a0c 100644 --- a/ServiceHost/Areas/Admin/Controllers/LoginController.cs +++ b/ServiceHost/Areas/Admin/Controllers/LoginController.cs @@ -4,7 +4,7 @@ using ServiceHost.BaseControllers; using ServiceHost.Controllers; namespace ServiceHost.Areas.Admin.Controllers; -public record GetAdminProfileDetails(long Id, string Fullname, string Mobile, string RoleName, List Permissions, long? PositionValue); +public record GetAdminProfileDetails(long Id, string Fullname, string Mobile, string RoleName, List Permissions, long? PositionValue,UserType UserType); public class LoginController:AdminBaseController { @@ -32,7 +32,8 @@ public class LoginController:AdminBaseController return NotFound("کاربر یافت نشد"); } - if (_authHelper.GetUserTypeWithId().userType is not UserType.Admin) + var userTypeWithId = _authHelper.GetUserTypeWithId(); + if (userTypeWithId.userType is not UserType.Admin) return Unauthorized(); var details = new GetAdminProfileDetails( @@ -41,7 +42,8 @@ public class LoginController:AdminBaseController data.Mobile, data.RoleName, data.Permissions, - data.PositionValue + data.PositionValue, + userTypeWithId.userType ); return details; } diff --git a/ServiceHost/Areas/Client/Controllers/LoginController.cs b/ServiceHost/Areas/Client/Controllers/LoginController.cs index 4879df1c..c3e7cd9f 100644 --- a/ServiceHost/Areas/Client/Controllers/LoginController.cs +++ b/ServiceHost/Areas/Client/Controllers/LoginController.cs @@ -6,7 +6,7 @@ using ServiceHost.BaseControllers; namespace ServiceHost.Areas.Client.Controllers; -public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List Permissions, List Workshops, string WorkshopSlug, double DebtAmount); +public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List Permissions, List Workshops, string WorkshopSlug, double DebtAmount,UserType UserType); public class LoginController : ClientBaseController { @@ -32,7 +32,8 @@ public class LoginController : ClientBaseController if (data == null) return Unauthorized(); - if (_authHelper.GetUserTypeWithId().userType is not UserType.Client and not UserType.SubAccount) + var userTypeWithId = _authHelper.GetUserTypeWithId(); + if (userTypeWithId.userType is not UserType.Client and not UserType.SubAccount) return Unauthorized(); var debtAmount = await _financialStatmentApplication.GetClientDebtAmount(data.Id); @@ -43,7 +44,8 @@ public class LoginController : ClientBaseController data.Permissions, data.WorkshopList, data.WorkshopSlug, - debtAmount + debtAmount, + userTypeWithId.userType ); return details; }