51 lines
2.0 KiB
Plaintext

@page "/auth/token"
@model DysonNetwork.Sphere.Pages.Auth.TokenModel
@{
ViewData["Title"] = "Authentication Successful";
Layout = "_Layout";
}
<div class="h-full flex items-center justify-center">
<div class="max-w-lg w-full mx-auto p-6 text-center">
<h1 class="text-2xl font-bold text-gray-900 dark:text-white">Authentication Successful</h1>
<p class="mb-6 text-gray-900 dark:text-white">You can now close this window and return to the application.</p>
</div>
</div>
@section Scripts {
<script>
(function() {
const urlParams = new URLSearchParams(window.location.search);
const token = urlParams.get('token');
if (token) {
console.log("Authentication token received.");
// For WebView2/UWP apps that can handle window.external.notify
if (window.external && typeof window.external.notify === 'function') {
try {
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 = `dyson://auth?token=${encodeURIComponent(token)}`;
window.location.href = customSchemeUrl;
console.log("Attempting to redirect to custom scheme:", customSchemeUrl);
} catch (e) {
console.error("Failed to redirect to custom scheme:", e);
}
} else {
console.error("Authentication token not found in URL.");
document.querySelector('p').innerText = "Authentication failed: No token was provided.";
}
})();
</script>
}