using Microsoft.AspNetCore.Http;
using System.Diagnostics.CodeAnalysis;
using Remotely.Server.Auth;
namespace Remotely.Server.Extensions;
public static class IHeaderDictionaryExtensions
{
///
/// If true, ensures that the user was authorized via ,
/// and is either an Administrator or is using a valid API access token.
///
///
///
///
public static bool TryGetOrganizationId(
this IHeaderDictionary headers,
[NotNullWhen(true)] out string? organizationId)
{
organizationId = null;
if (!headers.TryGetValue("OrganizationId", out var orgId))
{
return false;
}
organizationId = $"{orgId}";
if (string.IsNullOrWhiteSpace(organizationId))
{
return false;
}
return true;
}
}