Initial curated itworx-knowledge-hub source from 3b1751d0d9dee551aa6994eee0093704dc334817

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:37:37 +02:00
commit ad8ad252a9
825 files changed
+124216

No files matched your search

@@ -0,0 +1,44 @@
using ItWorx.KnowledgeHub.Domain.Identity;
namespace ItWorx.KnowledgeHub.Application.Identity.UseCases;
public sealed record SessionInfo(
bool Authenticated,
bool SetupRequired,
Guid? UserId,
string? DisplayName,
string? Email,
Guid? WorkspaceId,
WorkspaceRole? Role);
public sealed class GetSessionUseCase(
IInstallationRepository installations,
IUserAccountManager userAccounts,
IWorkspaceRepository workspaces,
IWorkspaceMembershipRepository memberships)
{
public async Task<SessionInfo> ExecuteAsync(CancellationToken cancellationToken)
{
var setupComplete = await installations.IsSetupCompleteAsync(cancellationToken);
var account = await userAccounts.GetSignedInAccountAsync(cancellationToken);
if (account is null)
{
return new SessionInfo(false, !setupComplete, null, null, null, null, null);
}
var workspaceId = await workspaces.GetDefaultWorkspaceIdAsync(cancellationToken);
WorkspaceRole? role = workspaceId is null
? null
: await memberships.GetRoleAsync(workspaceId.Value, account.Id, cancellationToken);
return new SessionInfo(
true,
!setupComplete,
account.Id,
account.DisplayName,
account.Email,
workspaceId,
role);
}
}