Initial TafsirQuran app with Gitea CI/CD deploy to k3s.
build-and-deploy / deploy (push) Successful in 10m50s
build-and-deploy / deploy (push) Successful in 10m50s
Blazor UI + ASP.NET API + Postgres; push to main builds images and rolls out namespace tafsirquran.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using Microsoft.JSInterop;
|
||||
using TafsirQuran.Shared.Services;
|
||||
|
||||
namespace TafsirQuran.UI.Services;
|
||||
|
||||
public class BrowserAuthTokenStore(IJSRuntime js) : IAuthTokenStore
|
||||
{
|
||||
private const string Key = "tq_auth_token";
|
||||
private string? _memory;
|
||||
private bool _loaded;
|
||||
|
||||
public async Task<string?> GetTokenAsync()
|
||||
{
|
||||
if (_loaded) return _memory;
|
||||
try
|
||||
{
|
||||
_memory = await js.InvokeAsync<string?>("tqStorage.get", Key);
|
||||
_loaded = true;
|
||||
return _memory;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return _memory;
|
||||
}
|
||||
catch (JSException)
|
||||
{
|
||||
return _memory;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SetTokenAsync(string? token)
|
||||
{
|
||||
_memory = token;
|
||||
_loaded = true;
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(token))
|
||||
await js.InvokeVoidAsync("tqStorage.remove", Key);
|
||||
else
|
||||
await js.InvokeVoidAsync("tqStorage.set", Key, token);
|
||||
}
|
||||
catch (InvalidOperationException) { }
|
||||
catch (JSException) { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user