110 lines
4.2 KiB
Plaintext
110 lines
4.2 KiB
Plaintext
@page "/auth/captcha"
|
|
@model DysonNetwork.Sphere.Pages.Checkpoint.CheckpointPage
|
|
|
|
@{
|
|
ViewData["Title"] = "Security Checkpoint";
|
|
var cfg = ViewData.Model.Configuration;
|
|
var provider = cfg.GetSection("Captcha")["Provider"]?.ToLower();
|
|
var apiKey = cfg.GetSection("Captcha")["ApiKey"];
|
|
}
|
|
|
|
@section Scripts {
|
|
@switch (provider)
|
|
{
|
|
case "recaptcha":
|
|
<script src="https://www.recaptcha.net/recaptcha/api.js" async defer></script>
|
|
break;
|
|
case "cloudflare":
|
|
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js" async defer></script>
|
|
break;
|
|
case "hcaptcha":
|
|
<script src="https://js.hcaptcha.com/1/api.js" async defer></script>
|
|
break;
|
|
}
|
|
|
|
<script>
|
|
function getQueryParam(name) {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
return urlParams.get(name);
|
|
}
|
|
|
|
function onSuccess(token) {
|
|
window.parent.postMessage("captcha_tk=" + token, "*");
|
|
const redirectUri = getQueryParam("redirect_uri");
|
|
if (redirectUri) {
|
|
window.location.href = `${redirectUri}?captcha_tk=${encodeURIComponent(token)}`;
|
|
}
|
|
}
|
|
</script>
|
|
}
|
|
|
|
<div class="h-full flex items-center justify-center">
|
|
<div class="max-w-lg w-full mx-auto p-6">
|
|
<div class="text-center">
|
|
<h1 class="text-2xl font-bold text-gray-900 dark:text-white">Security Check</h1>
|
|
<p class="mb-6 text-gray-900 dark:text-white">Please complete the contest below to confirm you're not a robot</p>
|
|
|
|
<div class="flex justify-center mb-8">
|
|
@switch (provider)
|
|
{
|
|
case "cloudflare":
|
|
<div class="cf-turnstile"
|
|
data-sitekey="@apiKey"
|
|
data-callback="onSuccess">
|
|
</div>
|
|
break;
|
|
case "recaptcha":
|
|
<div class="g-recaptcha"
|
|
data-sitekey="@apiKey"
|
|
data-callback="onSuccess">
|
|
</div>
|
|
break;
|
|
case "hcaptcha":
|
|
<div class="h-captcha"
|
|
data-sitekey="@apiKey"
|
|
data-callback="onSuccess">
|
|
</div>
|
|
break;
|
|
default:
|
|
<div class="p-4 bg-yellow-100 dark:bg-yellow-900 rounded-lg">
|
|
<p class="text-yellow-800 dark:text-yellow-200">
|
|
Captcha provider not configured correctly.
|
|
</p>
|
|
</div>
|
|
break;
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="mt-8 text-center text-sm">
|
|
<div class="font-semibold text-gray-700 dark:text-gray-300 mb-1">Solar Network Anti-Robot</div>
|
|
<div class="text-gray-600 dark:text-gray-400">
|
|
Powered by
|
|
@switch (provider)
|
|
{
|
|
case "cloudflare":
|
|
<a href="https://www.cloudflare.com/turnstile/"
|
|
class="hover:text-blue-600 dark:hover:text-blue-400 transition-colors">
|
|
Cloudflare Turnstile
|
|
</a>
|
|
break;
|
|
case "recaptcha":
|
|
<a href="https://www.google.com/recaptcha/"
|
|
class="hover:text-blue-600 dark:hover:text-blue-400 transition-colors">
|
|
Google reCaptcha
|
|
</a>
|
|
break;
|
|
default:
|
|
<span>Nothing</span>
|
|
break;
|
|
}
|
|
<br/>
|
|
Hosted by
|
|
<a href="https://github.com/Solsynth/DysonNetwork"
|
|
class="hover:text-blue-600 dark:hover:text-blue-400 transition-colors">
|
|
DysonNetwork.Sphere
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> |