src/fursvp.api/Filters/PrivateContentFilter.cs
/// <summary>
/// Ensures that the user is authorized to read a single element and filters out any unauthorized content within the element.
/// </summary>
/// <typeparam name="T">The type of the content to be searched.</typeparam>
/// <param name="content">The content being searched.</param>
/// <param name="readAuthorizeObject">Executes read authorization methods against this type of object.</param>
/// <param name="context">The Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext.</param>
Ensures that the user is authorized to read a single element and filters out any unauthorized content within the element.
Ensures that the user is authorized to read a single element and filters out any unauthorized content within the element .
public static void Filter<T>(T content, IReadAuthorize<T> readAuthorizeObject, ActionExecutedContext context)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }
            if (readAuthorizeObject == null)
            {
                throw new ArgumentNullException(nameof(readAuthorizeObject));
            }
            if (!readAuthorizeObject.CanRead(content))
            {
                context.Result = new UnauthorizedResult();
                return;
            }
            readAuthorizeObject.FilterUnauthorizedContent(content);
        }
public static void Filter < T > ( T content , IReadAuthorize < T > readAuthorizeObject , ActionExecutedContext context ) { if ( context == null ) { throw new ArgumentNullException ( nameof ( context ) ) ; } if ( readAuthorizeObject == null ) { throw new ArgumentNullException ( nameof ( readAuthorizeObject ) ) ; } if ( ! readAuthorizeObject . CanRead ( content ) ) { context . Result = new UnauthorizedResult ( ) ; return ; } readAuthorizeObject . FilterUnauthorizedContent ( content ) ; }
Ensures that the user is authorized to read a single element and filters out any unauthorized content within the element.
Ensures that the user is authorized to read a single element and filters out any unauthorized content within the element .
content
T
The content being searched.
The content being searched .
readAuthorizeObject
IReadAuthorize<T>
Executes read authorization methods against this type of object.
Executes read authorization methods against this type of object .
context
ActionExecutedContext
None
typeparam
The type of the content to be searched.
The type of the content to be searched .