Skip to content

Commit a7fda59

Browse files
authored
ft: API blocked warning (#92)
* add: warning if api is blocked * tweak
1 parent a0efc82 commit a7fda59

10 files changed

Lines changed: 1093 additions & 26 deletions

File tree

components/WarningApiBlock.vue

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<template>
2+
<div class="bg-yellow-900 p-4 space-y-2" role="alert">
3+
<p class="font-bold">
4+
😔 It seems you've blocked the Garden of Eden from accessing your dragons.
5+
</p>
6+
<p>While blocked, any dragons you add will be periodically removed.</p>
7+
<p>
8+
Even though the Garden uses your scroll authorisation, it still requires
9+
logged out access to be enabled. Don't worry, this is only used for
10+
assessing the state of your dragons and for performance reasons.
11+
</p>
12+
<p>
13+
To unblock, please press the unblock button next to "Garden of Eden" in
14+
your
15+
<NuxtLink to="https://dragcave.net/account/sessions#3rdparty"
16+
>Dragon Cave account settings</NuxtLink
17+
>, under "Logged Out Third-Party Access".
18+
</p>
19+
20+
<button class="btn-primary" type="button" @click="checkApiBlock()">
21+
Alright, I've unblocked. Let me in!
22+
</button>
23+
<p v-if="working">Checking...</p>
24+
<p v-else-if="failedToUnblock">
25+
It still seems you've got the Garden blocked. Please try again. If the
26+
issue persists,
27+
<NuxtLink
28+
to="https://forums.dragcave.net/topic/189636-chazzas-dc-tools-garden-of-eden-lineage-builder-fart/"
29+
>leave a message on the forum</NuxtLink
30+
>.
31+
</p>
32+
</div>
33+
</template>
34+
35+
<script lang="ts" setup>
36+
const failedToUnblock = ref(false);
37+
const working = ref(false);
38+
39+
const { data: authData } = useAuth();
40+
41+
async function checkApiBlock() {
42+
if (!authData.value?.user) {
43+
return;
44+
}
45+
46+
working.value = true;
47+
const blocked = await $fetch<true | false>('/api/user/scroll/check');
48+
49+
if (!blocked) {
50+
reloadNuxtApp();
51+
return;
52+
}
53+
54+
failedToUnblock.value = true;
55+
working.value = false;
56+
}
57+
</script>

database/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const userTable = mysqlTable(
3838
accessToken: char('access_token', {
3939
length: 129,
4040
}),
41+
apiBlocked: boolean('api_blocked').notNull().default(false),
4142
},
4243
(table) => {
4344
return {

drizzle/0033_fuzzy_moondragon.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE `users` ADD `api_blocked` boolean DEFAULT false NOT NULL;

0 commit comments

Comments
 (0)