Revise TBB and authentication logic

This commit is contained in:
2025-07-25 23:49:49 -06:00
parent 82166f5042
commit 9590a03cee
21 changed files with 70 additions and 213 deletions

View File

@@ -3,15 +3,15 @@
// AgileWebs
// </copyright>
// ***********************************************************************
using Core.Thalos.Adapters;
using Core.Blueprint.Mongo;
using Core.Blueprint.Redis;
using Core.Blueprint.Redis.Helpers;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.Domain.Contexts.Onboarding.Request;
using Core.Thalos.Provider.Contracts;
using Mapster;
using Microsoft.Extensions.Options;
using MongoDB.Driver;
using Core.Thalos.Provider.Contracts;
using Core.Thalos.Domain.Contexts.Onboarding.Request;
using Core.Blueprint.Redis;
using Core.Blueprint.Redis.Helpers;
namespace Core.Thalos.Provider.Providers.Onboarding
{

View File

@@ -6,7 +6,7 @@
using Core.Blueprint.Mongo;
using Core.Blueprint.Redis;
using Core.Blueprint.Redis.Helpers;
using Core.Thalos.Adapters;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.Domain.Contexts.Onboarding.Request;
using Core.Thalos.Provider.Contracts;
using Mapster;
@@ -128,7 +128,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding
/// <param name="newStatus">The new status of the permission.</param>
/// <returns>A <see cref="{Task{PermissionAdapter}}"/> representing
/// the asynchronous execution of the service.</returns>
public async ValueTask<PermissionAdapter> ChangePermissionStatus(string id, StatusEnum newStatus, CancellationToken cancellationToken)
public async ValueTask<PermissionAdapter> ChangePermissionStatus(string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken)
{
var entity = await repository.FindByIdAsync(id);
entity.Status = newStatus;

View File

@@ -6,18 +6,12 @@
using Core.Blueprint.Mongo;
using Core.Blueprint.Redis;
using Core.Blueprint.Redis.Helpers;
using Core.Thalos.Adapters;
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.Domain.Contexts.Onboarding.Request;
using Core.Thalos.Provider.Contracts;
using Mapster;
using Microsoft.Extensions.Options;
using Microsoft.Graph;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using System.ComponentModel.Design;
using System.Text.RegularExpressions;
namespace Core.Thalos.Provider.Providers.Onboarding
{
@@ -27,19 +21,19 @@ namespace Core.Thalos.Provider.Providers.Onboarding
public class RoleProvider : IRoleProvider
{
private readonly CollectionRepository<RoleAdapter> repository;
private readonly CacheSettings cacheSettings;
private readonly IRedisCacheProvider cacheProvider;
private readonly CacheSettings cacheSettings;
private readonly IRedisCacheProvider cacheProvider;
public RoleProvider(CollectionRepository<RoleAdapter> repository,
IRedisCacheProvider cacheProvider,
IOptions<CacheSettings> cacheSettings
)
public RoleProvider(CollectionRepository<RoleAdapter> repository,
IRedisCacheProvider cacheProvider,
IOptions<CacheSettings> cacheSettings
)
{
this.repository = repository;
this.repository.CollectionInitialization();
this.cacheSettings = cacheSettings.Value;
this.cacheProvider = cacheProvider;
}
this.cacheSettings = cacheSettings.Value;
this.cacheProvider = cacheProvider;
}
/// <summary>
/// Creates a new Role.

View File

@@ -7,15 +7,13 @@
using Core.Blueprint.Mongo;
using Core.Blueprint.Redis;
using Core.Blueprint.Redis.Helpers;
using Core.Thalos.Adapters;
using Core.Thalos.Adapters.Common.Enums;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.Provider.Contracts;
using Mapster;
using Microsoft.Extensions.Options;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver;
using System.Reflection;
using System.Text.RegularExpressions;
namespace Core.Thalos.Provider.Providers.Onboarding
@@ -27,18 +25,18 @@ namespace Core.Thalos.Provider.Providers.Onboarding
{
private readonly CollectionRepository<UserAdapter> repository;
private readonly CacheSettings cacheSettings;
private readonly IRedisCacheProvider cacheProvider;
private readonly IRedisCacheProvider cacheProvider;
public UserProvider(CollectionRepository<UserAdapter> repository,
public UserProvider(CollectionRepository<UserAdapter> repository,
IRedisCacheProvider cacheProvider,
IOptions<CacheSettings> cacheSettings
IOptions<CacheSettings> cacheSettings
)
{
this.repository = repository;
this.repository.CollectionInitialization();
this.cacheSettings = cacheSettings.Value;
this.cacheProvider = cacheProvider;
}
this.cacheSettings = cacheSettings.Value;
this.cacheProvider = cacheProvider;
}
/// <summary>
/// Creates a new User.
@@ -108,7 +106,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding
//if (cachedData is not null) { return cachedData; }
var user = await repository.FindOneAsync(
u => u.Email == email &&
u => u.Email == email &&
u.Status == Core.Blueprint.Mongo.StatusEnum.Active);
await cacheProvider.SetAsync(cacheKey, user);
@@ -419,7 +417,7 @@ namespace Core.Thalos.Provider.Providers.Onboarding
.Select(c => c.AsString)
.ToArray()
: Array.Empty<string>(),
Projects = result.Contains("projects") && result["projects"].IsBsonArray
Projects = result.Contains("projects") && result["projects"].IsBsonArray
? result["projects"].AsBsonArray
.Where(p => p != null && !p.IsBsonNull)
.Select(p => p.AsString)