5 Commits

Author SHA1 Message Date
7c92a7e791 Chande DI order 2025-07-27 19:35:00 -06:00
570e74a199 Remove unnecessary code from user services 2025-07-25 23:57:03 -06:00
9590a03cee Revise TBB and authentication logic 2025-07-25 23:49:49 -06:00
Oscar Morales
82166f5042 fix conflicts 2025-07-15 17:42:55 -06:00
Oscar Morales
a14cec8fb1 Configure authentication in program.cs and endpoints 2025-07-15 17:21:08 -06:00
22 changed files with 112 additions and 445 deletions

View File

@@ -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
{
@@ -25,7 +23,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[AllowAnonymous]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class ModuleController(IModuleProvider service) : ControllerBase
{
/// <summary>
@@ -39,8 +37,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read, RoleManagement.Read")]
[Permission("ModuleManagement.Read, RoleManagement.Read")]
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
{
var result = await service.GetAllModules(cancellationToken).ConfigureAwait(false);
@@ -60,8 +57,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<ModuleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetAllModulesByList([FromBody] string[] modules, CancellationToken cancellationToken)
{
if (modules == null || !modules.Any())
@@ -87,8 +83,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Read")]
[Permission("ModuleManagement.Read")]
public async Task<IActionResult> GetModuleByIdAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.GetModuleById(id, cancellationToken).ConfigureAwait(false);
@@ -111,8 +106,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal e|ror.</response>
[HttpPost]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken)
{
var result = await service.CreateModule(newModule, cancellationToken).ConfigureAwait(false);
@@ -134,8 +128,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> UpdateModuleAsync([FromRoute] string id, ModuleAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -163,8 +156,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(ModuleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("ModuleManagement.Write")]
[Permission("ModuleManagement.Write")]
public async Task<IActionResult> ChangeModuleStatus([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken)
{
var result = await service.ChangeModuleStatus(id, newStatus, cancellationToken).ConfigureAwait(false);

View File

@@ -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
{
@@ -25,6 +23,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class PermissionController(IPermissionProvider service) : ControllerBase
{
/// <summary>
@@ -38,8 +37,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read, RoleManagement.Read")]
[Permission("PermissionManagement.Read, RoleManagement.Read")]
public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken)
{
var result = await service.GetAllPermissions(cancellationToken).ConfigureAwait(false);
@@ -59,8 +57,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(IEnumerable<PermissionAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read")]
[Permission("PermissionManagement.Read")]
public async Task<IActionResult> GetAllPermissionsByList([FromBody] string[] permissions, CancellationToken cancellationToken)
{
if (permissions == null || !permissions.Any())
@@ -85,8 +82,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Read")]
[Permission("PermissionManagement.Read")]
public async Task<IActionResult> GetPermissionByIdAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.GetPermissionById(id, cancellationToken).ConfigureAwait(false);
@@ -109,8 +105,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal e|ror.</response>
[HttpPost]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken)
{
var result = await service.CreatePermission(newPermission, cancellationToken).ConfigureAwait(false);
@@ -132,8 +127,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> UpdatePermissionAsync([FromRoute] string id, PermissionAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -161,8 +155,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Consumes(MimeTypes.ApplicationJson)]
[Produces(MimeTypes.ApplicationJson)]
[ProducesResponseType(typeof(PermissionAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("PermissionManagement.Write")]
[Permission("PermissionManagement.Write")]
public async Task<IActionResult> ChangePermissionStatus([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken)
{
var result = await service.ChangePermissionStatus(id, newStatus, cancellationToken).ConfigureAwait(false);

View File

@@ -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;
@@ -24,6 +21,7 @@ namespace LSA.Core.Thalos.API.Controllers
[Produces(MimeTypes.ApplicationJson)]
[Consumes(MimeTypes.ApplicationJson)]
[ApiController]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
public class RoleController(IRoleProvider service) : ControllerBase
{
/// <summary>
@@ -35,8 +33,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<RoleAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Read")]
[Permission("RoleManagement.Read")]
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
{
var result = await service.GetAllRoles(cancellationToken).ConfigureAwait(false);
@@ -54,8 +51,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route(Routes.Id)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Read")]
[Permission("RoleManagement.Read")]
public async Task<IActionResult> GetRoleByIdAsync([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.GetRoleById(id, cancellationToken).ConfigureAwait(false);
@@ -78,8 +74,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPost]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken)
{
var result = await service.CreateRole(newRole, cancellationToken).ConfigureAwait(false);
@@ -99,8 +94,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPut]
[Route(Routes.Id)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> UpdateRoleAsync([FromRoute] string id, [FromBody] RoleAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -126,8 +120,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPatch]
[Route(Routes.ChangeStatus)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> ChangeRoleStatus([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken)
{
var result = await service.ChangeRoleStatus(id, newStatus, cancellationToken).ConfigureAwait(false);
@@ -146,8 +139,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPost(Routes.AddApplication)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> AddApplicationToRoleAsync([FromRoute] string roleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken)
{
var result = await service.AddApplicationToRole(roleId, application, cancellationToken).ConfigureAwait(false);
@@ -166,8 +158,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpDelete(Routes.RemoveApplication)]
[ProducesResponseType(typeof(RoleAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("RoleManagement.Write")]
[Permission("RoleManagement.Write")]
public async Task<IActionResult> RemoveApplicationFromRoleAsync([FromRoute] string roleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken)
{
var result = await service.RemoveApplicationFromRole(roleId, application, cancellationToken).ConfigureAwait(false);

View File

@@ -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
@@ -35,8 +33,8 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpGet]
[ProducesResponseType(typeof(IEnumerable<UserAdapter>), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Read")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Read")]
public async Task<IActionResult> GetAllUsers(CancellationToken cancellationToken)
{
var result = await service.GetAllUsers(cancellationToken).ConfigureAwait(false);
@@ -54,8 +52,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route(Routes.Id)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Read")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Read")]
public async Task<IActionResult> GetUserById([FromRoute] string id, CancellationToken cancellationToken)
{
var result = await service.GetUserById(id, cancellationToken).ConfigureAwait(false);
@@ -79,7 +77,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route(Routes.Email)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> GetUserByEmail([FromRoute] string email, CancellationToken cancellationToken)
{
var result = await service.GetUserByEmail(email, cancellationToken).ConfigureAwait(false);
@@ -127,8 +125,8 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPost(Routes.Register)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status201Created)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> CreateUserAsync([FromBody] UserRequest newUser, CancellationToken cancellationToken)
{
var result = await service.CreateUser(newUser, cancellationToken).ConfigureAwait(false);
@@ -148,8 +146,8 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPut]
[Route(Routes.Id)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> UpdateUserAsync([FromRoute] string id, [FromBody] UserAdapter entity, CancellationToken cancellationToken)
{
if (id != entity.Id?.ToString())
@@ -173,7 +171,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPatch(Routes.LogIn)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken)
{
var result = await service.LogInUser(email, cancellationToken).ConfigureAwait(false);
@@ -194,7 +192,7 @@ namespace LSA.Core.Thalos.API.Controllers
/// <response code="500">The service internal error.</response>
[HttpPatch(Routes.LogOut)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> LogOutUserSessionAsync([FromRoute] string email, CancellationToken cancellationToken)
{
var result = await service.LogOutUserSession(email, cancellationToken).ConfigureAwait(false);
@@ -216,94 +214,14 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpPatch]
[Route(Routes.ChangeStatus)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
[Permission("UserManagement.Write")]
public async Task<IActionResult> ChangeUserStatus([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken)
{
var result = await service.ChangeUserStatus(id, newStatus, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Adds a company to the user's list of companies.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="companyId">The company identifier to add.</param>
/// <returns>The updated <see cref="UserAdapter"/> entity.</returns>
/// <response code="200">The user with the updated companies.</response>
/// <response code="404">The user or company not found.</response>
/// <response code="500">The service internal error.</response>
[HttpPost]
[Route(Routes.AddCompany)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> AddCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken)
{
var result = await service.AddCompanyToUser(userId, companyId, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Removes a company from the user's list of companies.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="companyId">The company identifier to remove.</param>
/// <returns>The updated <see cref="UserAdapter"/> entity.</returns>
/// <response code="200">The user with the updated companies.</response>
/// <response code="404">The user or company not found.</response>
/// <response code="500">The service internal error.</response>
[HttpDelete]
[Route(Routes.RemoveCompany)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken)
{
var result = await service.RemoveCompanyFromUser(userId, companyId, cancellationToken).ConfigureAwait(false); ;
return Ok(result);
}
/// <summary>
/// Adds a project to the user's list of projects.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="projectId">The project identifier to add.</param>
/// <returns>The updated <see cref="UserAdapter"/> entity.</returns>
/// <response code="200">The user with the updated projects.</response>
/// <response code="404">The user or project not found.</response>
/// <response code="500">The service internal error.</response>
[HttpPost]
[Route(Routes.AddProject)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> AddProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken)
{
var result = await service.AddProjectToUser(userId, projectId, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Removes a project from the user's list of projects.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <param name="projectId">The project identifier to remove.</param>
/// <returns>The updated <see cref="UserAdapter"/> entity.</returns>
/// <response code="200">The user with the updated projects.</response>
/// <response code="404">The user or project not found.</response>
/// <response code="500">The service internal error.</response>
[HttpDelete]
[Route(Routes.RemoveProject)]
[ProducesResponseType(typeof(UserAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
//[Permission("UserManagement.Write")]
public async Task<IActionResult> RemoveProjectFromUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken)
{
var result = await service.RemoveProjectFromUser(userId, projectId, cancellationToken).ConfigureAwait(false);
return Ok(result);
}
/// <summary>
/// Gets a token for the user, including roles, permissions, and modules.
/// </summary>
@@ -315,7 +233,7 @@ namespace LSA.Core.Thalos.API.Controllers
[HttpGet]
[Route("{email}/GetTokenAdapter")]
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
//[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.AzureScheme}")]
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
public async Task<IActionResult> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken)
{
var tokenAdapter = await service.GetToken(email, cancellationToken).ConfigureAwait(false);

View File

@@ -1,71 +0,0 @@
using Asp.Versioning.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Any;
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)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen();
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
}
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("+", "."));
}
}
}

View File

@@ -1,8 +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.DAL.API.Extensions;
using Core.Thalos.BuildingBlocks;
using Core.Thalos.BuildingBlocks.Configuration;
using Core.Thalos.Provider;
using Microsoft.AspNetCore.HttpLogging;
using System.Reflection;
@@ -10,12 +11,19 @@ using System.Text.Json.Serialization;
var builder = WebApplication.CreateBuilder(args);
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();
@@ -42,11 +50,6 @@ builder.Host.ConfigureServices((context, services) =>
options.SerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
services
.AddEndpointsApiExplorer()
.AddVersioning()
.AddSwagger();
services.AddHealthChecks();
services.AddHttpLogging(options => options.LoggingFields = HttpLoggingFields.All);
@@ -63,20 +66,22 @@ builder.Host.ConfigureServices((context, services) =>
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.UseLogging(builder.Configuration);
app.UseSwaggerUI(builder.Configuration, authSettings);
app.ConfigureSwagger(builder.Configuration);
app.UseRouting();
app.UseCors();
app.ConfigureSwagger();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseResponseCompression();
app.UseOutputCache();
app.UseResponseCaching();
app.UseLogging(builder.Configuration);
app.UseAuthentication();
app.UseAuthorization();
app.MapControllers();
app.MapHealthChecks("/health");
app.Run();

View File

@@ -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
}
}

View File

@@ -4,19 +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
}
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -54,19 +54,5 @@ namespace Core.Thalos.Domain.Contexts.Onboarding.Request
[BsonRepresentation(BsonType.ObjectId)]
[JsonPropertyName("roleId")]
public string RoleId { get; set; } = null!;
/// <summary>
/// Gets or sets the array of companies associated with the user.
/// </summary>
[BsonElement("companies")]
[JsonPropertyName("companies")]
public string[] Companies { get; set; } = null!;
/// <summary>
/// Gets or sets the array of projects associated with the user.
/// </summary>
[BsonElement("projects")]
[JsonPropertyName("projects")]
public string[]? Projects { get; set; }
}
}

View File

@@ -7,7 +7,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.3" />
<PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.3" />
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.0.8" />
</ItemGroup>
</Project>

View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -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.
@@ -85,39 +84,6 @@ namespace Core.Thalos.Provider.Contracts
/// the asynchronous execution of the service.</returns>
ValueTask<UserAdapter?> LogOutUserSession(string email, CancellationToken cancellationToken);
/// <summary>
/// Adds a company to the user's list of companies.
/// </summary>
/// <param name="userId">The identifier of the user to whom the company will be added.</param>
/// <param name="companyId">The identifier of the company to add.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
ValueTask<UserAdapter> AddCompanyToUser(string userId, string companyId, CancellationToken cancellationToken);
/// <summary>
/// Removes a company from the user's list of companies.
/// </summary>
/// <param name="userId">The identifier of the user from whom the company will be removed.</param>
/// <param name="companyId">The identifier of the company to remove.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
ValueTask<UserAdapter> RemoveCompanyFromUser(string userId, string companyId, CancellationToken cancellationToken);
/// <summary>
/// Adds a project to the user's list of projects.
/// </summary>
/// <param name="userId">The identifier of the user to whom the project will be added.</param>
/// <param name="projectId">The identifier of the project to add.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
ValueTask<UserAdapter> AddProjectToUser(string userId, string projectId, CancellationToken cancellationToken);
/// <summary>
/// Removes a project from the user's list of projects.
/// </summary>
/// <param name="userId">The identifier of the user from whom the project will be removed.</param>
/// <param name="projectId">The identifier of the project to remove.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
ValueTask<UserAdapter> RemoveProjectFromUser(string userId, string projectId, CancellationToken cancellationToken);
/// <summary>
/// Gets the token adapter for a user.
/// </summary>

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);
@@ -211,92 +209,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding
return user;
}
/// <summary>
/// Adds a company to the user's list of companies.
/// </summary>
/// <param name="userId">The identifier of the user to whom the company will be added.</param>
/// <param name="companyId">The identifier of the company to add.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
public async ValueTask<UserAdapter> AddCompanyToUser(string userId, string companyId, CancellationToken cancellationToken)
{
var user = await repository.FindOneAsync(
u => u._Id == userId &&
u.Status == Core.Blueprint.Mongo.StatusEnum.Active);
var updatedCompanies = user.Companies.Append(companyId).Distinct().ToArray();
user.Companies = updatedCompanies;
await repository.ReplaceOneAsync(user);
return user;
}
/// <summary>
/// Removes a company from the user's list of companies.
/// </summary>
/// <param name="userId">The identifier of the user from whom the company will be removed.</param>
/// <param name="companyId">The identifier of the company to remove.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
public async ValueTask<UserAdapter> RemoveCompanyFromUser(string userId, string companyId, CancellationToken cancellationToken)
{
var user = await repository.FindOneAsync(
u => u._Id == userId &&
u.Status == Core.Blueprint.Mongo.StatusEnum.Active);
var updatedCompanies = user.Companies
?.Where(c => c != companyId)
.ToArray();
user.Companies = updatedCompanies;
await repository.ReplaceOneAsync(user);
return user;
}
/// <summary>
/// Adds a project to the user's list of projects.
/// </summary>
/// <param name="userId">The identifier of the user to whom the project will be added.</param>
/// <param name="projectId">The identifier of the project to add.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
public async ValueTask<UserAdapter> AddProjectToUser(string userId, string projectId, CancellationToken cancellationToken)
{
var user = await repository.FindOneAsync(
u => u._Id == userId &&
u.Status == Core.Blueprint.Mongo.StatusEnum.Active);
var updatedProjects = user.Projects.Append(projectId).Distinct().ToArray();
user.Projects = updatedProjects;
await repository.ReplaceOneAsync(user);
return user;
}
/// <summary>
/// Removes a project from the user's list of projects.
/// </summary>
/// <param name="userId">The identifier of the user from whom the project will be removed.</param>
/// <param name="projectId">The identifier of the project to remove.</param>
/// <returns>A <see cref="Task{UserAdapter}"/> representing the asynchronous operation, with the updated user object.</returns>
public async ValueTask<UserAdapter> RemoveProjectFromUser(string userId, string projectId, CancellationToken cancellationToken)
{
var user = await repository.FindOneAsync(
u => u._Id == userId &&
u.Status == Core.Blueprint.Mongo.StatusEnum.Active);
var updatedProjects = user.Projects
?.Where(c => c != projectId)
.ToArray();
user.Projects = updatedProjects;
await repository.ReplaceOneAsync(user);
return user;
}
/// <summary>
/// Gets the token adapter for a user.
/// </summary>
@@ -413,18 +325,6 @@ namespace Core.Thalos.Provider.Providers.Onboarding
LastName = result.Contains("lastName") && !result["lastName"].IsBsonNull ? result["lastName"].AsString : "",
DisplayName = result.Contains("displayName") && !result["displayName"].IsBsonNull ? result["displayName"].AsString : "",
RoleId = result.Contains("roleId") && !result["roleId"].IsBsonNull ? result["roleId"].ToString() : "",
Companies = result.Contains("companies") && result["companies"].IsBsonArray
? result["companies"].AsBsonArray
.Where(c => c != null && !c.IsBsonNull)
.Select(c => c.AsString)
.ToArray()
: Array.Empty<string>(),
Projects = result.Contains("projects") && result["projects"].IsBsonArray
? result["projects"].AsBsonArray
.Where(p => p != null && !p.IsBsonNull)
.Select(p => p.AsString)
.ToArray()
: Array.Empty<string>(),
LastLogIn = result.Contains("lastLogIn") && !result["lastLogIn"].IsBsonNull ? result["lastLogIn"].ToUniversalTime() : DateTime.MinValue,
LastLogOut = result.Contains("lastLogOut") && !result["lastLogOut"].IsBsonNull ? result["lastLogOut"].ToUniversalTime() : DateTime.MinValue,
CreatedAt = result.Contains("createdAt") && !result["createdAt"].IsBsonNull ? result["createdAt"].ToUniversalTime() : DateTime.MinValue,

View File

@@ -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;