48 lines
1.8 KiB
Plaintext
48 lines
1.8 KiB
Plaintext
@page "/auth/callback"
|
|
@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');
|
|
|
|
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?token=${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>
|
|
}
|