default user permission for guest requests
This commit is contained in:
parent
d5cf4451a2
commit
cd6097d133
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
|
using Data.Models.Client;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Razor.TagHelpers;
|
using Microsoft.AspNetCore.Razor.TagHelpers;
|
||||||
using SharedLibraryCore;
|
using SharedLibraryCore;
|
||||||
@ -30,7 +31,7 @@ public class HasPermission : TagHelper
|
|||||||
{
|
{
|
||||||
output.TagName = null;
|
output.TagName = null;
|
||||||
var permissionLevel = _contextAccessor?.HttpContext?.User.Claims
|
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) &&
|
var hasPermission = permissionLevel != null && _permissionSets.ContainsKey(permissionLevel) &&
|
||||||
_permissionSets[permissionLevel].HasPermission(Entity, Permission);
|
_permissionSets[permissionLevel].HasPermission(Entity, Permission);
|
||||||
|
Loading…
Reference in New Issue
Block a user