Introduced multiple controllers to enhance application functionality: - `AnnotationController`: Manages annotations and signature lifecycle. - `AuthController`: Handles user authentication and session management. - `CacheController`: Manages cached data for receivers. - `ConfigController`: Exposes client configuration data. - `DocumentController`: Provides access to envelope documents. - `EmailTemplateController`: Manages email templates. - `EnvelopeController`: Manages envelope operations. - `EnvelopeReceiverController`: Handles envelope receiver data. - `EnvelopeTypeController`: Retrieves envelope types. - `HistoryController`: Accesses envelope history. - `IAuthController`: Defines authentication interface. - `LocalizationController`: Manages localization settings. - `ReadOnlyController`: Manages read-only envelope sharing. - `ReceiverController`: Retrieves receiver data. - `SignatureController`: Retrieves document signatures. - `TfaRegistrationController`: Manages two-factor authentication. These changes improve maintainability and scalability by organizing operations into dedicated controllers.
38 lines
863 B
C#
38 lines
863 B
C#
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace EnvelopeGenerator.API.Controllers.Interfaces;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public interface IAuthController
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
IAuthorizationService AuthService { get; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
ClaimsPrincipal User { get; }
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public static class AuthControllerExtensions
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="controller"></param>
|
|
/// <param name="policyName"></param>
|
|
/// <returns></returns>
|
|
public static async Task<bool> IsUserInPolicyAsync(this IAuthController controller, string policyName)
|
|
{
|
|
var result = await controller.AuthService.AuthorizeAsync(controller.User, policyName);
|
|
return result.Succeeded;
|
|
}
|
|
} |