2020-06-15 18:49:54 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using MediaBrowser.Common.Net;
|
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
|
2020-08-06 14:17:45 +00:00
|
|
|
|
namespace Jellyfin.Api.Auth.IgnoreParentalControlPolicy
|
2020-06-15 18:49:54 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Escape schedule controls handler.
|
|
|
|
|
/// </summary>
|
2020-08-06 14:17:45 +00:00
|
|
|
|
public class IgnoreParentalControlHandler : BaseAuthorizationHandler<IgnoreParentalControlRequirement>
|
2020-06-15 18:49:54 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-08-06 14:17:45 +00:00
|
|
|
|
/// Initializes a new instance of the <see cref="IgnoreParentalControlHandler"/> class.
|
2020-06-15 18:49:54 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="userManager">Instance of the <see cref="IUserManager"/> interface.</param>
|
|
|
|
|
/// <param name="networkManager">Instance of the <see cref="INetworkManager"/> interface.</param>
|
|
|
|
|
/// <param name="httpContextAccessor">Instance of the <see cref="IHttpContextAccessor"/> interface.</param>
|
2020-08-06 14:17:45 +00:00
|
|
|
|
public IgnoreParentalControlHandler(
|
2020-06-15 18:49:54 +00:00
|
|
|
|
IUserManager userManager,
|
|
|
|
|
INetworkManager networkManager,
|
|
|
|
|
IHttpContextAccessor httpContextAccessor)
|
|
|
|
|
: base(userManager, networkManager, httpContextAccessor)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2020-08-06 14:17:45 +00:00
|
|
|
|
protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, IgnoreParentalControlRequirement requirement)
|
2020-06-15 18:49:54 +00:00
|
|
|
|
{
|
|
|
|
|
var validated = ValidateClaims(context.User, ignoreSchedule: true);
|
2020-10-14 23:58:46 +00:00
|
|
|
|
if (validated)
|
|
|
|
|
{
|
|
|
|
|
context.Succeed(requirement);
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-06-15 18:49:54 +00:00
|
|
|
|
{
|
|
|
|
|
context.Fail();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Task.CompletedTask;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|