Files
Swarm/DysonNetwork.Sphere/Pages/Auth/Callback.cshtml
2025-07-10 01:53:44 +08:00

49 lines
1.8 KiB
Plaintext

@page "/auth/callback"
@model DysonNetwork.Sphere.Pages.Auth.TokenModel
@{
ViewData["Title"] = "Authentication Successful";
Layout = "_Layout";
}
<div class="hero min-h-full bg-base-200">
<div class="hero-content text-center">
<div class="max-w-md">
<h1 class="text-5xl font-bold">Authentication Successful</h1>
<p class="py-6">You can now close this window and return to the application.</p>
</div>
</div>
</div>
@section Scripts {
<script>
(function () {
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('challenge');
console.log("Authentication token received.");
// For WebView2/UWP apps that can handle window.external.notify
if (window.external && typeof window.external.notify === 'function') {
try {
if (!token)
window.external.notify('done');
else
window.external.notify(token);
console.log("Token sent via window.external.notify.");
return; // Exit after successful notification
} catch (e) {
console.error("Failed to send token via window.external.notify:", e);
}
}
// For mobile apps that use custom URI schemes
try {
const customSchemeUrl = `solian://auth/callback?challenge=${encodeURIComponent(token ?? 'done')}`;
window.location.href = customSchemeUrl;
console.log("Attempting to redirect to custom scheme:", customSchemeUrl);
} catch (e) {
console.error("Failed to redirect to custom scheme:", e);
}
})();
</script>
}