add get profile
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
using _0_Framework.Application;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
using ServiceHost.Controllers;
|
||||
|
||||
namespace ServiceHost.Controllers;
|
||||
public record GetProfileDetails(long Id, string Fullname,UserType UserType ,string Mobile, string RoleName,List<int>Permissions,long? PositionValue);
|
||||
public class LoginController : GeneralBaseController
|
||||
namespace ServiceHost.Areas.Admin.Controllers;
|
||||
public record GetAdminProfileDetails(long Id, string Fullname, string Mobile, string RoleName, List<int> Permissions, long? PositionValue);
|
||||
|
||||
public class LoginController:AdminBaseController
|
||||
{
|
||||
|
||||
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public LoginController(IAuthHelper authHelper)
|
||||
@@ -15,23 +17,27 @@ public class LoginController : GeneralBaseController
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
/// <summary>
|
||||
/// جزئیات پروفایل کاربر جاری را برمی گرداند
|
||||
/// جزئیات پروفایل کاربر ادمین را برمی گرداند
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Profile")]
|
||||
public ActionResult<GetProfileDetails> GetProfile()
|
||||
public ActionResult<GetAdminProfileDetails> GetProfile()
|
||||
{
|
||||
if (!_authHelper.IsAuthenticated())
|
||||
return Unauthorized();
|
||||
|
||||
var data = _authHelper.CurrentAccountInfo();
|
||||
if (data == null)
|
||||
{
|
||||
return NotFound("کاربر یافت نشد");
|
||||
}
|
||||
var details = new GetProfileDetails(
|
||||
|
||||
if (_authHelper.GetUserTypeWithId().userType is not UserType.Admin)
|
||||
return Unauthorized();
|
||||
|
||||
var details = new GetAdminProfileDetails(
|
||||
data.Id,
|
||||
data.Fullname,
|
||||
_authHelper.GetUserTypeWithId().userType,
|
||||
data.Mobile,
|
||||
data.RoleName,
|
||||
data.Permissions,
|
||||
@@ -39,5 +45,4 @@ public class LoginController : GeneralBaseController
|
||||
);
|
||||
return details;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
44
ServiceHost/Areas/Client/Controllers/LoginController.cs
Normal file
44
ServiceHost/Areas/Client/Controllers/LoginController.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using _0_Framework.Application;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers;
|
||||
|
||||
public record GetClientProfileDetails(long Id, string Fullname, string Mobile, List<int> Permissions,List<WorkshopClaim> Workshops);
|
||||
|
||||
public class LoginController: ClientBaseController
|
||||
{
|
||||
private readonly IAuthHelper _authHelper;
|
||||
|
||||
public LoginController(IAuthHelper authHelper)
|
||||
{
|
||||
_authHelper = authHelper;
|
||||
}
|
||||
/// <summary>
|
||||
/// جزئیات پروفایل کاربر کلاینت را برمی گرداند
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("Profile")]
|
||||
public ActionResult<GetClientProfileDetails> GetProfile()
|
||||
{
|
||||
if (!_authHelper.IsAuthenticated())
|
||||
return Unauthorized();
|
||||
var data = _authHelper.CurrentAccountInfo();
|
||||
|
||||
if (data == null )
|
||||
return Unauthorized();
|
||||
|
||||
if (_authHelper.GetUserTypeWithId().userType is not UserType.Client and not UserType.SubAccount)
|
||||
return Unauthorized();
|
||||
|
||||
|
||||
var details = new GetClientProfileDetails(
|
||||
data.Id,
|
||||
data.Fullname,
|
||||
data.Mobile,
|
||||
data.Permissions,
|
||||
data.WorkshopList
|
||||
);
|
||||
return details;
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Areas\Client\Controllers\" />
|
||||
<Folder Include="Storage\Task\" />
|
||||
<Folder Include="Storage\Ticket\" />
|
||||
<Folder Include="wwwroot\AdminTheme\js\faceApi\" />
|
||||
|
||||
Reference in New Issue
Block a user