protected override async Task <Task> HandleRequirementAsync(AuthorizationHandlerContext context, CanChangeChannelSettingsRequirements requirement) { if ( context.User.IsInRole(Roles.Roles.IrcBot) || context.User.IsInRole(Roles.Roles.BotOwner) || context.User.IsInRole(Roles.Roles.BotAdmin) || context.User.IsInRole(Roles.Roles.ChannelBroadcaster) ) { context.Succeed(requirement); return(Task.CompletedTask); } string roomIdStr = context.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier)?.Value; if (string.IsNullOrEmpty(roomIdStr) || !int.TryParse(roomIdStr, out int roomId)) { return(Task.CompletedTask); } { // Mod check // TODO: Mod + ModAreEditors / Editor check Channel channel = _ttsDbContext.Channels .Include(c => c.ChannelEditors) .FirstOrDefault(c => c.RoomId == roomId); if (channel is not null) { string userIdStr = context.User.Claims.FirstOrDefault(c => c.Type == AuthClaims.UserId)?.Value; if (int.TryParse(userIdStr, out int userId)) { if (channel.ChannelEditors.Any(ce => ce.UserId == userId) || channel.AllModsAreEditors && await _moderation.IsModerator(channel, userId) ) { context.Succeed(requirement); } } } } return(Task.CompletedTask); }