48 lines
1.3 KiB
C#
48 lines
1.3 KiB
C#
using _0_Framework.Application;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ServiceHost.BaseControllers;
|
|
using ServiceHost.Controllers;
|
|
|
|
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)
|
|
{
|
|
_authHelper = authHelper;
|
|
}
|
|
/// <summary>
|
|
/// جزئیات پروفایل کاربر ادمین را برمی گرداند
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("Profile")]
|
|
public ActionResult<GetAdminProfileDetails> GetProfile()
|
|
{
|
|
if (!_authHelper.IsAuthenticated())
|
|
return Unauthorized();
|
|
|
|
var data = _authHelper.CurrentAccountInfo();
|
|
if (data == null)
|
|
{
|
|
return NotFound("کاربر یافت نشد");
|
|
}
|
|
|
|
if (_authHelper.GetUserTypeWithId().userType is not UserType.Admin)
|
|
return Unauthorized();
|
|
|
|
var details = new GetAdminProfileDetails(
|
|
data.Id,
|
|
data.Fullname,
|
|
data.Mobile,
|
|
data.RoleName,
|
|
data.Permissions,
|
|
data.PositionValue
|
|
);
|
|
return details;
|
|
}
|
|
} |