🐛 Fixes the callback page
This commit is contained in:
parent
3b9db74a34
commit
aba0f6b5e2
@ -14,36 +14,33 @@
|
|||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function () {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const token = urlParams.get('token');
|
const token = urlParams.get('token');
|
||||||
|
|
||||||
if (token) {
|
console.log("Authentication token received.");
|
||||||
console.log("Authentication token received.");
|
|
||||||
|
|
||||||
// For WebView2/UWP apps that can handle window.external.notify
|
// For WebView2/UWP apps that can handle window.external.notify
|
||||||
if (window.external && typeof window.external.notify === 'function') {
|
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 {
|
try {
|
||||||
const customSchemeUrl = `dyson://auth?token=${encodeURIComponent(token)}`;
|
if (!token)
|
||||||
window.location.href = customSchemeUrl;
|
window.external.notify('done');
|
||||||
console.log("Attempting to redirect to custom scheme:", customSchemeUrl);
|
else
|
||||||
|
window.external.notify(token);
|
||||||
|
console.log("Token sent via window.external.notify.");
|
||||||
|
return; // Exit after successful notification
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to redirect to custom scheme:", e);
|
console.error("Failed to send token via window.external.notify:", e);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
// For mobile apps that use custom URI schemes
|
||||||
console.error("Authentication token not found in URL.");
|
try {
|
||||||
document.querySelector('p').innerText = "Authentication failed: No token was provided.";
|
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>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user