last ...
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using xCommons.Extensions;
|
||||
using xIdentityModels.Dtos;
|
||||
using xExceptions.Constants;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace xIds.Providers
|
||||
{
|
||||
@@ -71,6 +73,14 @@ namespace xIds.Providers
|
||||
var responseJson = string.Empty;
|
||||
switch (requestModel.Action)
|
||||
{
|
||||
//
|
||||
case XOpenActions.GetApiKey:
|
||||
//
|
||||
ValidationProvider.NotEmpty(requestModel.Payload);
|
||||
var apiKeyId = await GetApiKey(requestModel);
|
||||
responseJson = apiKeyId.ToString();
|
||||
break;
|
||||
|
||||
//
|
||||
case XOpenActions.GetUserInfo:
|
||||
//
|
||||
@@ -129,6 +139,33 @@ namespace xIds.Providers
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Get Specified Api Key ...
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Guid> GetApiKey(
|
||||
XOpenActionRequestDto model,
|
||||
CancellationToken cancellationToken = default
|
||||
)
|
||||
{
|
||||
//
|
||||
var apiKey = await DbContext.ApiKeys
|
||||
.FirstOrDefaultAsync(x =>
|
||||
x.Key == model.Payload,
|
||||
cancellationToken: cancellationToken
|
||||
);
|
||||
var result = Guid.Empty;
|
||||
if (!apiKey.IsNullOrDefault())
|
||||
{
|
||||
result = apiKey.Id;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get User Info For Open Actions ...
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user