in packages/ekyc-api/src/ekyc-api/Controllers/LivenessController.cs [51:105]
public async Task<VerifyLivenessResponse> VerifyLiveness(string sessionId)
{
if (string.IsNullOrEmpty(sessionId))
throw new HttpStatusException(HttpStatusCode.InternalServerError, "Session ID must be provided.");
// Check if the session exists
var sessionValid = await _sessionManager.SessionExistsAndIsValid(sessionId);
if (!sessionValid)
throw new HttpStatusException(HttpStatusCode.InternalServerError,
$"Session ID {sessionId} not found or has expired.");
var error = await _livenessChecker.VerifyImageLiveness(sessionId);
var config = new DynamoDBOperationConfig
{
OverrideTableName = Globals.SessionTableName
};
var session = await _dbContext.LoadAsync<SessionObject>(sessionId, config);
var strClient = string.Empty;
if (HttpContext != null && HttpContext.Request != null &&
HttpContext.Request.Headers.ContainsKey("User-Agent"))
strClient = HttpContext.Request.Headers["User-Agent"].ToString();
var item = new VerificationHistoryItem
{
Id = sessionId,
Client = strClient,
Timestamp = Convert.ToInt64(DateTime.UtcNow.Subtract(DateTime.UnixEpoch).TotalSeconds),
IsSuccessful = string.IsNullOrEmpty(error),
Error = error,
documentType = session.documentType
};
config = new DynamoDBOperationConfig
{
OverrideTableName = Globals.VerificationHistoryTableName
};
await _dbContext.SaveAsync(item, config);
var response = new VerifyLivenessResponse
{
IsLive = string.IsNullOrEmpty(error),
Error = error
};
if (!string.IsNullOrEmpty(error))
await new Notifications().SendVerificationFailureNotification(session, error);
return response;
}