Files
SharepointToolbox-Web/Services/Session/UserSessionService.cs
T
kawa 5df7b72800 Add report logos and configurable folder scan depth
Report branding (top-left MSP logo, top-right client logo):
- Add MspLogo to AppSettings; client logo already on TenantProfile
- IUserSessionService.CurrentBranding composes MSP + active profile logo
- New reusable LogoUpload component (InputFile -> base64 LogoData, 512KB cap)
- MSP logo upload in Settings; optional client logo in profile create/edit
- Wire ReportBranding into all 6 HTML export pages
- Fix EditProfile dropping ClientLogo on edit

Storage metrics: expose folder scan depth (0-20) in scan options UI,
passed to existing StorageScanOptions.FolderDepth recursion.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 14:56:49 +02:00

55 lines
1.6 KiB
C#

using SharepointToolbox.Web.Core.Models;
using SharepointToolbox.Web.Infrastructure.Persistence;
namespace SharepointToolbox.Web.Services.Session;
public class UserSessionService : IUserSessionService
{
private readonly ISessionManager _sessionManager;
private readonly SettingsRepository _settingsRepo;
private TenantProfile? _currentProfile;
private AppSettings _settings = new();
public TenantProfile? CurrentProfile => _currentProfile;
public bool HasProfile => _currentProfile is not null;
public AppSettings Settings => _settings;
public ReportBranding CurrentBranding => new(_settings.MspLogo, _currentProfile?.ClientLogo);
public event Action? ProfileChanged;
public UserSessionService(ISessionManager sessionManager, SettingsRepository settingsRepo)
{
_sessionManager = sessionManager;
_settingsRepo = settingsRepo;
_ = LoadSettingsAsync();
}
public void SetProfile(TenantProfile profile)
{
_currentProfile = profile;
ProfileChanged?.Invoke();
}
public async Task ClearSessionAsync()
{
if (_currentProfile is not null)
await _sessionManager.ClearSessionAsync(_currentProfile.TenantUrl);
_currentProfile = null;
ProfileChanged?.Invoke();
}
public void UpdateSettings(AppSettings settings)
{
_settings = settings;
_ = _settingsRepo.SaveAsync(settings);
}
private async Task LoadSettingsAsync()
{
try { _settings = await _settingsRepo.LoadAsync(); }
catch { /* use defaults */ }
}
}