34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
using System;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace gehGassi.Web.Auth.Requirements
|
|
{
|
|
/// <summary>
|
|
/// Requirement für die Prüfung des Zugriffs auf einen AppUser
|
|
/// </summary>
|
|
public class AppUserRequirement : IAuthorizationRequirement
|
|
{
|
|
/// <summary>
|
|
/// Name des Parameters. Z.B. CustomerId oder CustomerUniqueId ...
|
|
/// </summary>
|
|
public string ParameterName { get; }
|
|
|
|
/// <summary>
|
|
/// Soll ein Administrator Zugriff haben auch wenn er nicht den Kunden zugeordnet hat?
|
|
/// </summary>
|
|
public bool AllowAdmin { get; set; }
|
|
|
|
/// <summary>
|
|
/// Erstellt eine Instanz
|
|
/// </summary>
|
|
/// <param name="parameterName">Name des Parameters</param>
|
|
/// <param name="allowAdmin">Soll ein Administrator Zugriff haben auch wenn er nicht den Kunden zugeordnet hat?</param>
|
|
/// <exception cref="ArgumentException"></exception>
|
|
public AppUserRequirement(string parameterName, bool allowAdmin = false)
|
|
{
|
|
ParameterName = parameterName ?? throw new ArgumentException(nameof(parameterName));
|
|
AllowAdmin = allowAdmin;
|
|
}
|
|
}
|
|
}
|