🐛 Trying to fix permission that inherits from groups.
This commit is contained in:
parent
9e7ba820c4
commit
185ab13ec9
@ -19,7 +19,7 @@ public class RealtimeCallController(IConfiguration configuration, AppDatabase db
|
|||||||
|
|
||||||
[HttpGet("{roomId:guid}/join")]
|
[HttpGet("{roomId:guid}/join")]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<IActionResult> JoinCall(Guid roomId)
|
public async Task<ActionResult<JoinCallResponse>> JoinCall(Guid roomId)
|
||||||
{
|
{
|
||||||
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
if (HttpContext.Items["CurrentUser"] is not Account.Account currentUser) return Unauthorized();
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ public class PermissionService(
|
|||||||
public async Task<T?> GetPermissionAsync<T>(string actor, string area, string key)
|
public async Task<T?> GetPermissionAsync<T>(string actor, string area, string key)
|
||||||
{
|
{
|
||||||
var cacheKey = _GetPermissionCacheKey(actor, area, key);
|
var cacheKey = _GetPermissionCacheKey(actor, area, key);
|
||||||
|
|
||||||
var cachedValue = await cache.GetAsync<T>(cacheKey);
|
var cachedValue = await cache.GetAsync<T>(cacheKey);
|
||||||
if (cachedValue != null)
|
if (cachedValue != null)
|
||||||
{
|
{
|
||||||
@ -43,19 +43,19 @@ public class PermissionService(
|
|||||||
|
|
||||||
var now = SystemClock.Instance.GetCurrentInstant();
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
var groupsKey = _GetGroupsCacheKey(actor);
|
var groupsKey = _GetGroupsCacheKey(actor);
|
||||||
|
|
||||||
var groupsId = await cache.GetAsync<List<Guid>>(groupsKey);
|
var groupsId = await cache.GetAsync<List<Guid>>(groupsKey);
|
||||||
if (groupsId == null)
|
if (groupsId == null)
|
||||||
{
|
{
|
||||||
groupsId = await db.PermissionGroupMembers
|
groupsId = await db.PermissionGroupMembers
|
||||||
.Where(n => n.Actor == actor)
|
.Where(n => n.Actor == "user:" + actor)
|
||||||
.Where(n => n.ExpiredAt == null || n.ExpiredAt < now)
|
.Where(n => n.ExpiredAt == null || n.ExpiredAt < now)
|
||||||
.Where(n => n.AffectedAt == null || n.AffectedAt >= now)
|
.Where(n => n.AffectedAt == null || n.AffectedAt >= now)
|
||||||
.Select(e => e.GroupId)
|
.Select(e => e.GroupId)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
await cache.SetWithGroupsAsync(groupsKey, groupsId,
|
await cache.SetWithGroupsAsync(groupsKey, groupsId,
|
||||||
new[] { _GetPermissionGroupKey(actor) },
|
[_GetPermissionGroupKey(actor)],
|
||||||
CacheExpiration);
|
CacheExpiration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class PermissionService(
|
|||||||
await cache.SetWithGroupsAsync(cacheKey, result,
|
await cache.SetWithGroupsAsync(cacheKey, result,
|
||||||
[_GetPermissionGroupKey(actor)],
|
[_GetPermissionGroupKey(actor)],
|
||||||
CacheExpiration);
|
CacheExpiration);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,9 +75,9 @@
|
|||||||
"SubjectPrefix": "Solar Network"
|
"SubjectPrefix": "Solar Network"
|
||||||
},
|
},
|
||||||
"RealtimeChat": {
|
"RealtimeChat": {
|
||||||
"Endpoint": "",
|
"Endpoint": "https://solar-network-im44o8gq.livekit.cloud",
|
||||||
"ApiKey": "",
|
"ApiKey": "APIs6TiL8wj3A4j",
|
||||||
"ApiSecret": ""
|
"ApiSecret": "SffxRneIwTnlHPtEf3zicmmv3LUEl7xXael4PvWZrEhE"
|
||||||
},
|
},
|
||||||
"GeoIp": {
|
"GeoIp": {
|
||||||
"DatabasePath": "./Keys/GeoLite2-City.mmdb"
|
"DatabasePath": "./Keys/GeoLite2-City.mmdb"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user