🐛 Fixes the callback page

This commit is contained in:
LittleSheep 2025-06-17 23:27:49 +08:00
parent 3b9db74a34
commit aba0f6b5e2

View File

@ -14,16 +14,18 @@
@section Scripts {
<script>
(function() {
(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 {
if (!token)
window.external.notify('done');
else
window.external.notify(token);
console.log("Token sent via window.external.notify.");
return; // Exit after successful notification
@ -34,17 +36,12 @@
// For mobile apps that use custom URI schemes
try {
const customSchemeUrl = `dyson://auth?token=${encodeURIComponent(token)}`;
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);
}
} else {
console.error("Authentication token not found in URL.");
document.querySelector('p').innerText = "Authentication failed: No token was provided.";
}
})();
</script>
}