Table of Contents

Class CurrentUser

Namespace
KadicErp.WebApi.Infrastructure.Security
Assembly
KadicErp.WebApi.dll
public class CurrentUser : ICurrentUser, ITenantContext
Inheritance
object
CurrentUser
Implements
ICurrentUser
ITenantContext

Properties

Email

public string Email { get; }

Property Value

string

IsAuthenticated

public bool IsAuthenticated { get; }

Property Value

bool

IsPlatformAdmin

Set when the authenticated caller holds an active platform-admin grant at the moment the JWT was issued. This is a HINT derived from a JWT claim — handlers that enforce cross-tenant bypass MUST still re-verify against IPlatformAdminService to shrink the revocation window to the service's cache duration (seconds, not the JWT lifetime).

public bool IsPlatformAdmin { get; }

Property Value

bool

IsTenantSuperAdmin

Hint from JWT claim 'tenant_super_admin'. Handlers MUST re-verify via ITenantSuperAdminService (30-second cache) before granting bypass.

public bool IsTenantSuperAdmin { get; }

Property Value

bool

Permissions

public IReadOnlyCollection<string> Permissions { get; }

Property Value

IReadOnlyCollection<string>

RoleIds

Tenant role IDs assigned to this user (JWT roleId claim). A user can hold more than one role assignment (e.g. branch-scoped roles), so this is a collection rather than a single value — callers that need "the" role for a self-service lookup (e.g. resolving which dashboard configuration belongs to the caller) should take the first entry.

public IReadOnlyCollection<Guid> RoleIds { get; }

Property Value

IReadOnlyCollection<Guid>

Roles

public IReadOnlyCollection<string> Roles { get; }

Property Value

IReadOnlyCollection<string>

TenantBranchId

public Guid TenantBranchId { get; }

Property Value

Guid

TenantBranchIds

public IReadOnlyCollection<Guid> TenantBranchIds { get; }

Property Value

IReadOnlyCollection<Guid>

TenantId

public Guid TenantId { get; }

Property Value

Guid

UserId

public Guid UserId { get; }

Property Value

Guid

Username

public string Username { get; }

Property Value

string

Methods

Clear()

public void Clear()

HasAllPermissions(params string[])

public bool HasAllPermissions(params string[] permissionCodes)

Parameters

permissionCodes string[]

Returns

bool

HasAnyPermission(params string[])

public bool HasAnyPermission(params string[] permissionCodes)

Parameters

permissionCodes string[]

Returns

bool

HasPermission(string)

public bool HasPermission(string permissionCode)

Parameters

permissionCode string

Returns

bool

SetAuthenticated(Guid, Guid, Guid, IEnumerable<Guid>, string?, string?, IEnumerable<string>, IEnumerable<string>, bool, bool, IEnumerable<Guid>?)

public void SetAuthenticated(Guid userId, Guid tenantId, Guid tenantBranchId, IEnumerable<Guid> tenantBranchIds, string? username, string? email, IEnumerable<string> roles, IEnumerable<string> permissions, bool isPlatformAdmin = false, bool isTenantSuperAdmin = false, IEnumerable<Guid>? roleIds = null)

Parameters

userId Guid
tenantId Guid
tenantBranchId Guid
tenantBranchIds IEnumerable<Guid>
username string
email string
roles IEnumerable<string>
permissions IEnumerable<string>
isPlatformAdmin bool
isTenantSuperAdmin bool
roleIds IEnumerable<Guid>