default user permission for guest requests

This commit is contained in:
RaidMax 2022-09-19 22:01:34 -05:00
parent d5cf4451a2
commit cd6097d133

View File

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using Data.Models.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Razor.TagHelpers;
using SharedLibraryCore;
@ -30,7 +31,7 @@ public class HasPermission : TagHelper
{
output.TagName = null;
var permissionLevel = _contextAccessor?.HttpContext?.User.Claims
.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?.Value;
.FirstOrDefault(claim => claim.Type == ClaimTypes.Role)?.Value ?? EFClient.Permission.User.ToString();
var hasPermission = permissionLevel != null && _permissionSets.ContainsKey(permissionLevel) &&
_permissionSets[permissionLevel].HasPermission(Entity, Permission);