5a23783e07
- Add missing modal CSS (.modal-overlay/.modal-dialog/.modal-header): the "Connect to Microsoft" auth modal was rendering unstyled inline at the bottom of the page. Now a centered dialog with backdrop. - Surface OAuth connect errors in the modal instead of silently reopening it with no explanation. - MainLayout: implement IDisposable so event handlers are actually unsubscribed (Dispose existed but was never invoked). - Wire up the Settings theme selector (was a dead control): drop the unsupported Dark option, call sptb.setTheme on save and on load, resolve System via prefers-color-scheme. - Add branded 404 page via UseStatusCodePagesWithReExecute + Routes <NotFound> (blank white page before). - Add .progress-fill.indeterminate animation and .progress-panel. - Home: replace inline JS hover handlers with a .feature-card CSS class. - Define missing --surface-2 variable referenced by MainLayout. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
79 lines
2.6 KiB
Plaintext
79 lines
2.6 KiB
Plaintext
@inject ISessionCredentialStore CredStore
|
|
@inject IUserSessionService Session
|
|
@inject ISessionManager SessionManager
|
|
@inject NavigationManager Nav
|
|
@using SharepointToolbox.Web.Core.Models
|
|
@using SharepointToolbox.Web.Services.Session
|
|
|
|
@if (_visible)
|
|
{
|
|
<div class="modal-overlay" role="dialog" aria-modal="true" aria-labelledby="connect-modal-title">
|
|
<div class="modal-dialog">
|
|
<div class="modal-header">
|
|
<h3 id="connect-modal-title">Connect to Microsoft</h3>
|
|
<p class="text-muted">
|
|
Authenticate to access <strong>@Session.CurrentProfile?.Name</strong>.
|
|
Your session token is stored in your browser only — never saved to disk.
|
|
</p>
|
|
</div>
|
|
|
|
@if (!string.IsNullOrEmpty(_error))
|
|
{
|
|
<div class="alert alert-error">@_error</div>
|
|
}
|
|
|
|
<div class="modal-footer">
|
|
<button class="btn btn-secondary" @onclick="Cancel" disabled="@_connecting">Cancel</button>
|
|
<button class="btn btn-primary" @onclick="ConnectAsync" disabled="@_connecting">
|
|
@(_connecting ? "Redirecting…" : "Connect via Microsoft")
|
|
</button>
|
|
</div>
|
|
|
|
<p class="text-muted" style="font-size:11px;margin-top:8px;text-align:right">
|
|
You will be redirected to Microsoft login. MFA is supported.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
[Parameter] public EventCallback OnConnected { get; set; }
|
|
|
|
private bool _visible;
|
|
private bool _connecting;
|
|
private string _error = string.Empty;
|
|
|
|
public async Task ShowAsync(string? error = null)
|
|
{
|
|
_error = error ?? string.Empty;
|
|
_connecting = false;
|
|
_visible = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async Task ConnectAsync()
|
|
{
|
|
var profile = Session.CurrentProfile;
|
|
if (profile is null) { _error = "No client profile selected."; return; }
|
|
|
|
_connecting = true;
|
|
_error = string.Empty;
|
|
|
|
// Clear any stale CSOM contexts
|
|
await SessionManager.ClearAllAsync();
|
|
|
|
var currentUrl = Nav.Uri;
|
|
var connectUrl = $"/connect/initiate?profileId={Uri.EscapeDataString(profile.Id)}" +
|
|
$"&returnUrl={Uri.EscapeDataString(currentUrl)}";
|
|
|
|
// Force full HTTP navigation to break out of the Blazor SignalR circuit
|
|
Nav.NavigateTo(connectUrl, forceLoad: true);
|
|
}
|
|
|
|
private void Cancel()
|
|
{
|
|
_visible = false;
|
|
_connecting = false;
|
|
}
|
|
}
|