feat: add auth gate
This commit is contained in:
parent
24d9d524a2
commit
902c0fea0e
23
index.html
23
index.html
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue