feat: add permission handling methods and project board detail query

This commit is contained in:
2025-12-16 12:56:49 +03:30
parent f7351454f3
commit 2972807c9f
7 changed files with 133 additions and 24 deletions

View File

@@ -1,5 +1,6 @@
using System.Security.Claims;
using GozareshgirProgramManager.Application._Common.Interfaces;
using GozareshgirProgramManager.Domain._Common;
using Microsoft.AspNetCore.Http;
namespace GozareshgirProgramManager.Infrastructure.Services.Authentication;
@@ -106,6 +107,21 @@ public class AuthHelper : IAuthHelper
return _httpContextAccessor.HttpContext?.User?.FindFirst("FullName")?.Value;
}
public bool HasPermission(int permission)
{
return GetPermissions().Any(x => x == permission);
}
public List<int> GetPermissions()
{
if (!IsAuthenticated())
return new List<int>();
var permissions = _httpContextAccessor.HttpContext.User.Claims.FirstOrDefault(x => x.Type == "permissions")
?.Value;
return Tools.DeserializeFromBsonList<int>(permissions); //Mahan
}
// /// <summary>
// /// دریافت AccountId کاربر جاری از Claims
// /// </summary>