72 lines
3.1 KiB
C#
72 lines
3.1 KiB
C#
namespace NTP.Application.Auth;
|
|
|
|
public sealed class UserLoginRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? RoleCode { get; set; }
|
|
public string? EmpNo { get; set; }
|
|
public long? LocationId { get; set; }
|
|
}
|
|
|
|
/// <summary>Legacy info.getConactInfo (ntpusers joined to companies).</summary>
|
|
public sealed class UserProfileRow
|
|
{
|
|
public long Id { get; set; }
|
|
public string? DomainName { get; set; }
|
|
public string? Name { get; set; }
|
|
public string? RoleCode { get; set; }
|
|
public string? EmpNo { get; set; }
|
|
public long? LocationId { get; set; }
|
|
public long? CompanyId { get; set; }
|
|
public string? ResetPassword { get; set; }
|
|
public string? CompanyName { get; set; }
|
|
public string? CompanyCode { get; set; }
|
|
}
|
|
|
|
public sealed class UserHierarchyRow
|
|
{
|
|
public long? CompanyId { get; set; }
|
|
public long? GroupId { get; set; }
|
|
public long? StakeholderId { get; set; }
|
|
}
|
|
|
|
public sealed class LocationRow
|
|
{
|
|
public string? Type { get; set; }
|
|
public string? Name { get; set; }
|
|
}
|
|
|
|
public sealed record AuditLogEntry(string? DoneBy, string? Ip, string? DoneByRole, int LogType, string? DoneByName, string? Browser);
|
|
|
|
public sealed record InvalidAccessEntry(
|
|
long UserDbId, long? LocationId, string RoleCode, string ValidIps, string RemoteIp,
|
|
string? RemoteIpLocationId, string? UserAgent, int ReasonId);
|
|
|
|
public interface IAuthRepository
|
|
{
|
|
/// <summary>Credential check. <paramref name="requireActiveCompany"/> mirrors the ASEZA branch (join COMPANIES, status = 1).</summary>
|
|
Task<UserLoginRow?> FindActiveUserByPasswordAsync(string login, string domain, IReadOnlyList<string> passwordCandidates,
|
|
bool requireActiveCompany, CancellationToken ct = default);
|
|
|
|
/// <summary>GateEventsFactory.CheckAuthorization: active UTT (booth) row for the login.</summary>
|
|
Task<bool> HasActiveBoothAsync(string login, CancellationToken ct = default);
|
|
|
|
Task<UserProfileRow?> GetProfileAsync(string login, string domain, CancellationToken ct = default);
|
|
Task<string?> GetRoleNameAsync(string roleCode, CancellationToken ct = default);
|
|
Task<UserHierarchyRow?> GetHierarchyAsync(long userDbId, CancellationToken ct = default);
|
|
Task<LocationRow?> GetLocationAsync(long locationId, string? domain, CancellationToken ct = default);
|
|
|
|
/// <summary>Application.cfc onRequestStart: still active, same role.</summary>
|
|
Task<bool> IsActiveWithRoleAsync(string login, string roleCode, CancellationToken ct = default);
|
|
|
|
Task<int> UpdatePasswordAsync(string login, string domain, string newPassword, string updatedBy, CancellationToken ct = default);
|
|
|
|
Task<IReadOnlyList<string>> GetLocationIpsAsync(string locationId, CancellationToken ct = default);
|
|
/// <summary>LOCATIONS_IPS.LOCATION_ID that owns this IP, or null.</summary>
|
|
Task<string?> GetLocationForIpAsync(string ip, CancellationToken ct = default);
|
|
Task InsertInvalidAccessLogAsync(InvalidAccessEntry entry, CancellationToken ct = default);
|
|
|
|
/// <summary>logs.addLog: LOGS row (1 = sign in, 2 = sign out, 35 = SSO).</summary>
|
|
Task InsertLogAsync(AuditLogEntry entry, CancellationToken ct = default);
|
|
}
|