feat: add auth gate

This commit is contained in:
posimai 2026-04-05 02:54:21 +09:00
parent 24d9d524a2
commit 902c0fea0e
1 changed files with 23 additions and 0 deletions

View File

@ -4,6 +4,29 @@
<head>
<meta charset="UTF-8">
<meta name="robots" content="noindex, nofollow">
<!-- Auth Gate -->
<script>
(function () {
var apiKey = localStorage.getItem('posimai_api_key') || '';
var token = localStorage.getItem('posimai_token') || '';
if (!apiKey && !token) {
location.href = 'https://posimai.soar-enrich.com/login?redirect=' + encodeURIComponent(location.href);
return;
}
if (token && !apiKey) {
fetch('https://api.soar-enrich.com/brain/api/auth/session/verify', {
headers: { 'Authorization': 'Bearer ' + token }
}).then(function (r) { return r.json(); }).then(function (d) {
if (!d.ok) {
localStorage.removeItem('posimai_token');
location.href = 'https://posimai.soar-enrich.com/login?redirect=' + encodeURIComponent(location.href);
} else if (!d.purchased) {
location.href = 'https://store.posimai.soar-enrich.com/index-c.html';
}
}).catch(function () { /* オフライン時は通す */ });
}
})();
</script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
<meta name="description" content="ITエンジニア・デザイナーの学習を加速するイベント情報">
<title>Posimai Tech Events</title>