feat: add permission handling methods and project board detail query
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user