✨ Self-contained oidc receiver page
This commit is contained in:
50
DysonNetwork.Sphere/Pages/Auth/Token.cshtml
Normal file
50
DysonNetwork.Sphere/Pages/Auth/Token.cshtml
Normal file
@ -0,0 +1,50 @@
|
||||
@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>
|
||||
}
|
11
DysonNetwork.Sphere/Pages/Auth/Token.cshtml.cs
Normal file
11
DysonNetwork.Sphere/Pages/Auth/Token.cshtml.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace DysonNetwork.Sphere.Pages.Auth
|
||||
{
|
||||
public class TokenModel : PageModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user