Initial commit

This commit is contained in:
2026-06-02 10:51:14 +02:00
committed by kawa
commit d19092c84e
182 changed files with 13757 additions and 0 deletions
@@ -0,0 +1,42 @@
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using SharepointToolbox.Web.Core.Models;
namespace SharepointToolbox.Web.Services.Session;
public class SessionCredentialStore : ISessionCredentialStore
{
private const string Key = "sp-session-tokens";
private readonly ProtectedSessionStorage _storage;
public SessionCredentialStore(ProtectedSessionStorage storage) { _storage = storage; }
public async Task<SessionTokens?> GetAsync()
{
try
{
var result = await _storage.GetAsync<SessionTokens>(Key);
return result.Success ? result.Value : null;
}
catch { return null; }
}
public async Task SetAsync(SessionTokens tokens) =>
await _storage.SetAsync(Key, tokens);
public async Task UpdateRefreshTokenAsync(string newRefreshToken)
{
var tokens = await GetAsync();
if (tokens is null) return;
tokens.RefreshToken = newRefreshToken;
await _storage.SetAsync(Key, tokens);
}
public async Task ClearAsync() =>
await _storage.DeleteAsync(Key);
public async Task<bool> HasCredentialsAsync()
{
var tokens = await GetAsync();
return tokens is not null && !string.IsNullOrEmpty(tokens.RefreshToken);
}
}