last ...
This commit is contained in:
@@ -5,6 +5,8 @@ using xIdentityModels.Models;
|
||||
using xIdentityModels.Constants;
|
||||
using System.Collections.Generic;
|
||||
using xIdentityModels.Configurations;
|
||||
using Microsoft.OpenApi.Expressions;
|
||||
using System;
|
||||
|
||||
namespace xIdentityModels.Extensions
|
||||
{
|
||||
@@ -161,7 +163,7 @@ namespace xIdentityModels.Extensions
|
||||
)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
source.Roles
|
||||
.Any(r => roles
|
||||
@@ -195,5 +197,54 @@ namespace xIdentityModels.Extensions
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Api Key is Revoked or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsRevoked(this XApiKey source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
source.RevokedAt.HasValue;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Api Key is Expired or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExpired(this XApiKey source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
DateTime.UtcNow >= source.ExpiresAt;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check Specified Api Key is Active or not ...
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsActive(this XApiKey source)
|
||||
{
|
||||
//
|
||||
var result =
|
||||
!source.IsNullOrDefault() &&
|
||||
!source.IsRevoked() &&
|
||||
!source.IsExpired();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user