Revise TBB and authentication logic
This commit is contained in:
@@ -5,15 +5,13 @@
|
||||
// ***********************************************************************
|
||||
|
||||
using Asp.Versioning;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Provider.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Graph;
|
||||
using ModuleRequest = Core.Thalos.Domain.Contexts.Onboarding.Request.ModuleRequest;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
|
||||
namespace LSA.Core.Thalos.API.Controllers
|
||||
{
|
||||
|
||||
@@ -5,15 +5,13 @@
|
||||
// ***********************************************************************
|
||||
|
||||
using Asp.Versioning;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Provider.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Graph;
|
||||
using PermissionRequest = Core.Thalos.Domain.Contexts.Onboarding.Request.PermissionRequest;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
|
||||
namespace LSA.Core.Thalos.API.Controllers
|
||||
{
|
||||
|
||||
@@ -4,10 +4,7 @@
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Asp.Versioning;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Domain.Contexts.Onboarding.Request;
|
||||
using Core.Thalos.Provider.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Asp.Versioning;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Attributes;
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Provider.Contracts;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Graph;
|
||||
using StatusEnum = Core.Blueprint.Mongo.StatusEnum;
|
||||
using UserRequest = Core.Thalos.Domain.Contexts.Onboarding.Request.UserRequest;
|
||||
|
||||
namespace LSA.Core.Thalos.API.Controllers
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Graph.ExternalConnectors;
|
||||
using Microsoft.OpenApi.Any;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
|
||||
namespace Core.Thalos.DAL.API.Extensions
|
||||
{
|
||||
public static class SwaggerExtensions
|
||||
{
|
||||
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddEndpointsApiExplorer();
|
||||
AddSwaggerGen(services, configuration);
|
||||
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
|
||||
}
|
||||
|
||||
public static void AddSwaggerGen(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
Description = "JWT Authorization header using the Bearer scheme",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.Http,
|
||||
Scheme = "bearer",
|
||||
BearerFormat = "JWT"
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
Array.Empty<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static void ConfigureSwagger(this WebApplication app)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
|
||||
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
|
||||
|
||||
options.DisplayRequestDuration();
|
||||
options.EnableTryItOutByDefault();
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
});
|
||||
}
|
||||
public static IServiceCollection AddVersioning(this IServiceCollection services)
|
||||
{
|
||||
services.AddApiVersioning(options => options.ReportApiVersions = true)
|
||||
.AddApiExplorer(options =>
|
||||
{
|
||||
options.GroupNameFormat = "'v'VVV";
|
||||
options.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
public class ConfigureSwaggerOptions : IConfigureOptions<SwaggerGenOptions>
|
||||
{
|
||||
private readonly IApiVersionDescriptionProvider _provider;
|
||||
|
||||
public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider)
|
||||
{
|
||||
_provider = provider;
|
||||
}
|
||||
|
||||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
foreach (var description in _provider.ApiVersionDescriptions)
|
||||
options.SwaggerDoc(description.GroupName, new()
|
||||
{
|
||||
Title = AppDomain.CurrentDomain.FriendlyName,
|
||||
Version = description.ApiVersion.ToString()
|
||||
});
|
||||
|
||||
//Map ALL Values Format TODO
|
||||
options.MapType<DateOnly>(() => new()
|
||||
{
|
||||
Format = "date",
|
||||
Example = new OpenApiString(DateOnly.MinValue.ToString())
|
||||
});
|
||||
|
||||
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using Core.Blueprint.DAL.Mongo.Configuration;
|
||||
using Core.Blueprint.KeyVault.Configuration;
|
||||
using Core.Blueprint.Logging.Configuration;
|
||||
using Core.Blueprint.Redis.Configuration;
|
||||
using Core.Thalos.Adapters.Extensions;
|
||||
using Core.Thalos.BuildingBlocks.Authentication.Extensions;
|
||||
using Core.Thalos.DAL.API.Extensions;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.BuildingBlocks.Configuration;
|
||||
using Core.Thalos.Provider;
|
||||
using Microsoft.AspNetCore.HttpLogging;
|
||||
using System.Reflection;
|
||||
@@ -11,14 +11,19 @@ using System.Text.Json.Serialization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.ConfigureAuthentication(builder.Configuration);
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
builder.Configuration
|
||||
.AddUserSecrets(Assembly.GetExecutingAssembly())
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
var services = builder.Services.AddKeyVault(builder.Configuration);
|
||||
|
||||
var authSettings = await AuthHelper.GetAuthSettings(builder.Services, builder, "thalos_common");
|
||||
|
||||
builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
|
||||
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(builder.Configuration, "Core.Thalos.DAL.API.xml", authSettings);
|
||||
builder.Services.AddVersioning(builder.Configuration);
|
||||
builder.Services.AddResponseCompression();
|
||||
builder.Services.AddProblemDetails();
|
||||
builder.Services.AddMemoryCache();
|
||||
@@ -45,11 +50,6 @@ builder.Host.ConfigureServices((context, services) =>
|
||||
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
|
||||
});
|
||||
|
||||
services
|
||||
.AddEndpointsApiExplorer()
|
||||
.AddVersioning()
|
||||
.AddSwagger(builder.Configuration);
|
||||
|
||||
services.AddHealthChecks();
|
||||
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
|
||||
|
||||
@@ -66,11 +66,10 @@ builder.Host.ConfigureServices((context, services) =>
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwaggerUI(builder.Configuration, authSettings);
|
||||
app.MapControllers();
|
||||
app.UseCors();
|
||||
app.ConfigureSwagger();
|
||||
app.ConfigureSwagger(builder.Configuration);
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
app.UseRouting();
|
||||
|
||||
@@ -22,5 +22,14 @@
|
||||
"ServiceSettings": {
|
||||
"ApplicationName": "thalos",
|
||||
"LayerName": "dal"
|
||||
},
|
||||
"Vault": {
|
||||
"Address": "http://100.123.31.103:8200",
|
||||
"Token": "hvs.e37LQvLuPhTd5ALS5QQ03Cwm",
|
||||
"SecretMount": "secret"
|
||||
},
|
||||
"IdentityProviders": {
|
||||
"Google": true,
|
||||
"Azure": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,32 +4,5 @@
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"MongoDB": "mongodb://admin_agile:Admin%40agileWebs@portainer.white-enciso.pro:27017/?authMechanism=SCRAM-SHA-256",
|
||||
"Redis": "localhost:6379"
|
||||
},
|
||||
"MongoDb": {
|
||||
"DatabaseName": "Thalos",
|
||||
"LocalAudience": ""
|
||||
},
|
||||
"DetailedErrors": true,
|
||||
"UseRedisCache": true,
|
||||
"CacheSettings": {
|
||||
"DefaultCacheDurationInMinutes": 3
|
||||
},
|
||||
"Authentication": {
|
||||
"Google": {
|
||||
"ClientId": "128345072002-mtfdgpcur44o9tbd7q6e0bb9qnp2crfp.apps.googleusercontent.com",
|
||||
"ClientSecret": "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",
|
||||
"ApplicationName": "Thalos",
|
||||
"RedirectUri": "https://localhost:7239/api/v1/Authentication/callback"
|
||||
}
|
||||
},
|
||||
"JwtIssuerOptions": {
|
||||
"Audience": "https://localhost:7239/",
|
||||
"Issuer": "webApi"
|
||||
},
|
||||
"SecretKey": "iNivDmHLpUA223sqsfhqGbMRdRj1PVkH1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using Core.Thalos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.5" />
|
||||
<PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.3" />
|
||||
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.7" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Domain.Contexts.Onboarding.Request;
|
||||
|
||||
namespace Core.Thalos.Provider.Contracts
|
||||
@@ -50,7 +49,7 @@ namespace Core.Thalos.Provider.Contracts
|
||||
/// <returns>The <see cref="ModuleAdapter"/> updated entity.</returns>
|
||||
/// <returns>A <see cref="{Task{ModuleAdapter}}"/> representing
|
||||
/// the asynchronous execution of the service.</returns>
|
||||
ValueTask<ModuleAdapter> ChangeModuleStatus(string id, StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
ValueTask<ModuleAdapter> ChangeModuleStatus(string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a Module by id.
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Domain.Contexts.Onboarding.Request;
|
||||
|
||||
namespace Core.Thalos.Provider.Contracts
|
||||
@@ -50,7 +49,7 @@ namespace Core.Thalos.Provider.Contracts
|
||||
/// <returns>The <see cref="PermissionAdapter"/> updated entity.</returns>
|
||||
/// <returns>A <see cref="{Task{PermissionAdapter}}"/> representing
|
||||
/// the asynchronous execution of the service.</returns>
|
||||
ValueTask<PermissionAdapter> ChangePermissionStatus(string id, StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
ValueTask<PermissionAdapter> ChangePermissionStatus(string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a Permission by id.
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Domain.Contexts.Onboarding.Request;
|
||||
|
||||
namespace Core.Thalos.Provider.Contracts
|
||||
|
||||
@@ -3,8 +3,7 @@
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Domain.Contexts.Onboarding.Request;
|
||||
|
||||
namespace Core.Thalos.Provider.Contracts
|
||||
@@ -58,7 +57,7 @@ namespace Core.Thalos.Provider.Contracts
|
||||
/// <param name="newStatus">The new status of the user.</param>
|
||||
/// <returns>A <see cref="{Task{UserAdapter}}"/> representing
|
||||
/// the asynchronous execution of the service.</returns>
|
||||
ValueTask<UserAdapter> ChangeUserStatus(string id, StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
ValueTask<UserAdapter> ChangeUserStatus(string id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Updates a User by id.
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Core.Blueprint.Mongo;
|
||||
using Core.Thalos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.Provider.Contracts;
|
||||
using Core.Thalos.Provider.Providers.Onboarding;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
Reference in New Issue
Block a user