First Commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using ADS.Apis.Gps.Application.Abstractions.Security;
|
||||
using ADS.Helpers.Data.Abstractions;
|
||||
|
||||
namespace ADS.Apis.Gps.Infrastructure.Security;
|
||||
|
||||
public sealed class AdsClientCredentialValidator : IAdsClientCredentialValidator
|
||||
{
|
||||
private readonly ITenantDbConnectionFactory _db;
|
||||
|
||||
public AdsClientCredentialValidator(ITenantDbConnectionFactory db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public async Task<AdsClientCredentialResult> ValidateAsync(string clientId, string clientSecret, CancellationToken ct = default)
|
||||
{
|
||||
// using var conn = await _db.OpenAsync(ct);
|
||||
|
||||
// var p = new DynamicParameters();
|
||||
// p.Add("@ClientId", clientId, DbType.String);
|
||||
// p.Add("@ClientSecret", clientSecret, DbType.String);
|
||||
|
||||
// var row = await conn.QueryFirstOrDefaultAsync<ClientRow>(
|
||||
// sql: "PA_Sicrep_ValidateClient",
|
||||
// param: p,
|
||||
// commandType: CommandType.StoredProcedure
|
||||
// );
|
||||
|
||||
// if (row is null || row.IsValid == 0)
|
||||
// return new AdsClientCredentialResult(false, null, null, null);
|
||||
|
||||
// return new AdsClientCredentialResult(true, row.ClientId, row.ClientKey, row.ClientName);
|
||||
return null;
|
||||
}
|
||||
|
||||
private sealed class ClientRow
|
||||
{
|
||||
public int IsValid { get; init; }
|
||||
public int ClientId { get; init; }
|
||||
public string ClientKey { get; init; } = string.Empty;
|
||||
public string ClientName { get; init; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Data;
|
||||
using Dapper;
|
||||
using ADS.Apis.Gps.Application.Abstractions.Security;
|
||||
using ADS.Helpers.Data.Abstractions;
|
||||
|
||||
namespace ADS.Apis.Gps.Infrastructure.Security;
|
||||
|
||||
public sealed class AdsUserCredentialValidator : IAdsUserCredentialValidator
|
||||
{
|
||||
private readonly ITenantDbConnectionFactory _db;
|
||||
|
||||
public AdsUserCredentialValidator(ITenantDbConnectionFactory db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
public async Task<AdsUserCredentialResult> ValidateAsync(string username, string password, CancellationToken ct = default)
|
||||
{
|
||||
// using var conn = await _db.OpenAsync(ct);
|
||||
|
||||
// // EJEMPLO: si validas con SP
|
||||
// // Cambia el nombre del SP y los nombres de parámetros a tus reales.
|
||||
// var p = new DynamicParameters();
|
||||
// p.Add("@Usuario", username, DbType.String);
|
||||
// p.Add("@Password", password, DbType.String);
|
||||
|
||||
// var row = await conn.QueryFirstOrDefaultAsync<UserRow>(
|
||||
// sql: "PA_Sicrep_ValidateUser",
|
||||
// param: p,
|
||||
// commandType: CommandType.StoredProcedure
|
||||
// );
|
||||
|
||||
// if (row is null || row.IsValid == 0)
|
||||
// return new AdsUserCredentialResult(false, null, null, null);
|
||||
|
||||
// return new AdsUserCredentialResult(true, row.UserId, row.Username, row.DisplayName);
|
||||
return null;
|
||||
}
|
||||
|
||||
private sealed class UserRow
|
||||
{
|
||||
public int IsValid { get; init; }
|
||||
public int UserId { get; init; }
|
||||
public string Username { get; init; } = string.Empty;
|
||||
public string DisplayName { get; init; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user