Skip to content

Commit 6394331

Browse files
authored
Hotfix v0.3.1
2 parents 00224bd + 7d95250 commit 6394331

20 files changed

Lines changed: 460 additions & 56 deletions

File tree

assets/tailwindcss.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,12 @@
22
@plugin "@tailwindcss/typography";
33
@plugin "@tailwindcss/forms";
44
@config "../tailwind.config.js";
5+
6+
@layer base {
7+
input[type="number"]::-webkit-outer-spin-button,
8+
input[type="number"]::-webkit-inner-spin-button,
9+
input[type="number"] {
10+
-webkit-appearance: none;
11+
-moz-appearance: textfield !important;
12+
}
13+
}

components/UserHeader/UserWidget.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ const navigation = computed<NavigationItem[]>(() =>
100100
route: "/account",
101101
prefix: "",
102102
},
103+
{
104+
label: "Authorize client",
105+
route: "/client/code",
106+
prefix: "",
107+
},
103108
].filter((e) => e !== undefined),
104109
);
105110
</script>

i18n/locales/en_au.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
{
22
"setup": {
33
"welcome": "G'day."
4+
},
5+
"account": {
6+
"devices": {
7+
"subheader": "Manage the devices authorised to access your Drop account."
8+
}
9+
},
10+
"auth": {
11+
"callback": {
12+
"authClient": "Authorise client?",
13+
"authorize": "Authorise",
14+
"authorizedClient": "Drop has successfully authorised the client. You may now close this window."
15+
}
16+
},
17+
"library": {
18+
"collection": {
19+
"subheader": "Add a new collection to organise your games"
20+
},
21+
"subheader": "Organise your games into collections for easy access, and access all your games."
422
}
523
}

i18n/locales/en_pirate.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,25 @@
109109
"listItemPlaceholder": "list item, eh?"
110110
},
111111
"errors": {
112+
"admin": {
113+
"user": {
114+
"delete": {
115+
"desc": "Couldn't make {0} walk the plank!",
116+
"title": "Couldn't make 'em walk the plank"
117+
}
118+
}
119+
},
120+
"auth": {
121+
"disabled": "Ya' angered the Cap'n, give him a holler!",
122+
"invalidInvite": "Boarding pass no longer valid, ya scallywag!",
123+
"invalidPassState": "Cap'n's rolled snake eyes, see how he's doin'.",
124+
"invalidUserOrPass": "Are ya lying to me about your username and password, ya dog?",
125+
"inviteIdRequired": "Ya need to include the ID for your boarding pass, matey!",
126+
"method": {
127+
"signinDisabled": "No entrance through these parts, arr!"
128+
},
129+
"usernameTaken": "We already have a scallywag with that 'ere name of yours."
130+
},
112131
"backHome": "{arrow} Back to yer safe harbor",
113132
"game": {
114133
"banner": {
@@ -203,7 +222,8 @@
203222
"discord": "Discord, argh!",
204223
"github": "GitHub, savvy?"
205224
},
206-
"topSellers": "Top Plunderers"
225+
"topSellers": "Top Plunderers",
226+
"version": "Drop {version} {gitRef}"
207227
},
208228
"header": {
209229
"admin": {
@@ -401,7 +421,8 @@
401421
"cleanupSessionsDescription": "Cleans up expired sessions to save space and keep ye safe, ye dog!",
402422
"cleanupSessionsName": "Clean up sessions."
403423
},
404-
"viewTask": "View {arrow}"
424+
"viewTask": "View {arrow}",
425+
"weeklyScheduledTitle": "Weekly chores"
405426
}
406427
},
407428
"title": "Drop",
@@ -439,6 +460,8 @@
439460
"title": "Passage"
440461
},
441462
"authoptionsHeader": "Passage Options",
463+
"delete": "Scuttle!",
464+
"deleteUser": "Make {0} walk the plank!",
442465
"description": "Manage the crew on yer Drop vessel, and set yer passage methods, savvy?",
443466
"displayNameHeader": "Scallywag Name",
444467
"emailHeader": "Salty Mail",

i18n/locales/en_us.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"requestedAccess": "\"{name}\" has requested access to your Drop account.",
3939
"success": "Successful!"
4040
},
41+
"code": {
42+
"title": "Connect your Drop client",
43+
"description": "Use a code to connect your Drop client if you are unable to open a web browser on your device."
44+
},
4145
"confirmPassword": "Confirm @:auth.password",
4246
"displayName": "Display Name",
4347
"email": "Email",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drop",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"private": true,
55
"type": "module",
66
"license": "AGPL-3.0-or-later",
Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div
33
v-if="completed"
4-
class="min-h-full w-full flex items-center justify-center"
4+
class="min-h-full w-full flex items-center justify-center py-10"
55
>
66
<div class="flex flex-col items-center">
77
<CheckCircleIcon class="h-12 w-12 text-green-600" aria-hidden="true" />
@@ -14,7 +14,7 @@
1414
{{ $t("auth.callback.authorizedClient") }}
1515
</p>
1616

17-
<Disclosure v-slot="{ open }" as="div" class="mt-8">
17+
<Disclosure v-if="authToken" v-slot="{ open }" as="div" class="mt-8">
1818
<dt>
1919
<DisclosureButton
2020
class="pb-2 flex w-full items-start justify-between text-left text-zinc-400"
@@ -155,38 +155,58 @@ import {
155155
XCircleIcon,
156156
} from "@heroicons/vue/16/solid";
157157
import { LockClosedIcon } from "@heroicons/vue/20/solid";
158-
import { CheckCircleIcon } from "@heroicons/vue/24/outline";
158+
import { CheckCircleIcon, CloudIcon } from "@heroicons/vue/24/outline";
159159
import { ChevronDownIcon, ChevronUpIcon } from "@heroicons/vue/24/solid";
160+
import type { FetchError } from "ofetch";
160161
161162
const route = useRoute();
162163
const clientId = route.params.id;
163164
164-
const clientData = await $dropFetch(
165-
`/api/v1/client/auth/callback?id=${clientId}`,
166-
);
165+
const clientData = await $dropFetch(`/api/v1/client/auth?id=${clientId}`);
167166
168167
const completed = ref(false);
169168
const error = ref();
170169
const authToken = ref<string | undefined>();
171170
172171
async function authorize() {
173-
const { redirect, token } = await $dropFetch("/api/v1/client/auth/callback", {
174-
method: "POST",
175-
body: { id: clientId },
172+
switch (clientData.mode) {
173+
case "callback": {
174+
const { redirect, token } = await $dropFetch(
175+
`/api/v1/client/auth/callback`,
176+
{
177+
method: "POST",
178+
body: { id: clientId },
179+
},
180+
);
181+
authToken.value = token;
182+
window.location.replace(redirect);
183+
return;
184+
}
185+
case "code": {
186+
await $dropFetch("/api/v1/client/auth/code", {
187+
method: "POST",
188+
body: { id: clientId },
189+
});
190+
return;
191+
}
192+
}
193+
throw createError({
194+
statusCode: 500,
195+
statusMessage: "Unknown client auth mode: " + clientData.mode,
196+
fatal: true,
176197
});
177-
authToken.value = token;
178-
window.location.replace(redirect);
179198
}
180199
181-
function authorize_wrapper() {
182-
authorize()
183-
.catch((e) => {
184-
const errorMessage = e.statusMessage || "An unknown error occurred.";
185-
error.value = errorMessage;
186-
})
187-
.then(() => {
188-
completed.value = true;
189-
});
200+
async function authorize_wrapper() {
201+
try {
202+
await authorize();
203+
} catch (e) {
204+
const errorMessage =
205+
(e as FetchError)?.statusMessage || "An unknown error occurred.";
206+
error.value = errorMessage;
207+
} finally {
208+
completed.value = true;
209+
}
190210
}
191211
192212
const scopes = [
@@ -198,20 +218,27 @@ const scopes = [
198218
icon: ArrowDownTrayIcon,
199219
},
200220
{
221+
name: "Update your status",
222+
description:
223+
"The client will be able to update your status, and affect your playtime.",
224+
href: "/docs/access/status",
225+
icon: UserGroupIcon,
226+
},
227+
clientData.capabilities["peerAPI"] && {
201228
name: "Access the Drop network",
202229
description:
203230
"The client will be able to establish P2P connections with other users to enable features like download aggregation, Remote LAN play and P2P multiplayer.",
204231
href: "/docs/access/network",
205232
icon: LockClosedIcon,
206233
},
207-
{
208-
name: "Manage your account",
234+
clientData.capabilities["cloudSaves"] && {
235+
name: "Upload and sync cloud saves",
209236
description:
210-
"The client will be able to change your account details, and friend statuses on your behalf.",
211-
href: "/docs/access/account",
212-
icon: UserGroupIcon,
237+
"The client will be able to upload new cloud saves, and edit your existing ones.",
238+
href: "/docs/access/cloud",
239+
icon: CloudIcon,
213240
},
214-
];
241+
].filter((e) => e !== undefined);
215242
216243
useHead({
217244
title: "Authorize",

pages/client/code/index.vue

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<template>
2+
<div class="w-full h-max min-h-[30vw] flex items-center justify-center">
3+
<div class="text-center">
4+
<h1 class="text-2xl font-bold text-zinc-100">
5+
{{ $t("auth.code.title") }}
6+
</h1>
7+
<p class="mt-1 max-w-sm text-zinc-400 mx-auto">
8+
{{ $t("auth.code.description") }}
9+
</p>
10+
<div v-if="!loading" class="mt-8 flex flex-row gap-4">
11+
<input
12+
v-for="i in codeLength"
13+
ref="codeElements"
14+
:key="i"
15+
v-model="code[i - 1]"
16+
class="uppercase w-16 h-16 appearance-none text-center bg-zinc-900 rounded-xl border-zinc-700 focus:border-blue-600 text-2xl text-bold font-display text-zinc-100"
17+
type="text"
18+
pattern="\d*"
19+
:placeholder="placeholder[i - 1]"
20+
@keydown="(v) => keydown(i - 1, v)"
21+
@input="() => input(i - 1)"
22+
@focusin="() => select(i - 1)"
23+
@paste="(v) => paste(i - 1, v)"
24+
/>
25+
</div>
26+
<div v-else class="mt-8 flex items-center justify-center">
27+
<svg
28+
aria-hidden="true"
29+
class="size-12 text-transparent animate-spin fill-white"
30+
viewBox="0 0 100 101"
31+
fill="none"
32+
xmlns="http://www.w3.org/2000/svg"
33+
>
34+
<path
35+
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
36+
fill="currentColor"
37+
/>
38+
<path
39+
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
40+
fill="currentFill"
41+
/>
42+
</svg>
43+
</div>
44+
45+
<div
46+
v-if="error"
47+
class="mt-8 rounded-md bg-red-600/10 p-4 max-w-sm mx-auto"
48+
>
49+
<div class="flex">
50+
<div class="flex-shrink-0">
51+
<XCircleIcon class="h-5 w-5 text-red-600" aria-hidden="true" />
52+
</div>
53+
<div class="ml-3">
54+
<h3 class="text-sm font-medium text-red-600">
55+
{{ error }}
56+
</h3>
57+
</div>
58+
</div>
59+
</div>
60+
</div>
61+
</div>
62+
</template>
63+
64+
<script setup lang="ts">
65+
import { XCircleIcon } from "@heroicons/vue/24/solid";
66+
import { FetchError } from "ofetch";
67+
68+
const codeLength = 7;
69+
const placeholder = "1A2B3C4";
70+
const codeElements = useTemplateRef("codeElements");
71+
const code = ref<string[]>([]);
72+
73+
const router = useRouter();
74+
const loading = ref(false);
75+
const error = ref<string | undefined>(undefined);
76+
77+
function keydown(index: number, event: KeyboardEvent) {
78+
if (event.key === "Backspace" && !code.value[index] && index > 0) {
79+
codeElements.value![index - 1].focus();
80+
}
81+
}
82+
83+
function input(index: number) {
84+
if (codeElements.value === null) return;
85+
const v = code.value[index] ?? "";
86+
if (v.length > 1) code.value[index] = v[0];
87+
88+
if (!(index + 1 >= codeElements.value.length) && v) {
89+
codeElements.value[index + 1].focus();
90+
}
91+
92+
if (!(index - 1 < 0) && !v) {
93+
codeElements.value[index - 1].focus();
94+
}
95+
96+
console.log(index, codeLength - 1);
97+
if (index == codeLength - 1) {
98+
const assembledCode = code.value.join("");
99+
if (assembledCode.length == codeLength) {
100+
complete(assembledCode);
101+
}
102+
}
103+
}
104+
105+
function select(index: number) {
106+
if (!codeElements.value) return;
107+
if (index >= codeElements.value.length) return;
108+
codeElements.value[index].select();
109+
}
110+
111+
function paste(index: number, event: ClipboardEvent) {
112+
const newCode = event.clipboardData!.getData("text/plain");
113+
for (let i = 0; i < newCode.length && i < codeLength; i++) {
114+
code.value[i] = newCode[i];
115+
codeElements.value![i].focus();
116+
}
117+
event.preventDefault();
118+
}
119+
120+
async function complete(code: string) {
121+
loading.value = true;
122+
try {
123+
const clientId = await $dropFetch(`/api/v1/client/auth/code?code=${code}`);
124+
router.push(`/client/authorize/${clientId}`);
125+
} catch (e) {
126+
if (e instanceof FetchError) {
127+
error.value =
128+
e.statusMessage ?? e.message ?? "An unknown error occurred.";
129+
} else {
130+
error.value = (e as string)?.toString();
131+
}
132+
}
133+
loading.value = false;
134+
}
135+
</script>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- DropForeignKey
2+
ALTER TABLE "Game" DROP CONSTRAINT "Game_libraryId_fkey";
3+
4+
-- DropIndex
5+
DROP INDEX "GameTag_name_idx";
6+
7+
-- CreateIndex
8+
CREATE INDEX "GameTag_name_idx" ON "GameTag" USING GIST ("name" gist_trgm_ops(siglen=32));
9+
10+
-- AddForeignKey
11+
ALTER TABLE "Game" ADD CONSTRAINT "Game_libraryId_fkey" FOREIGN KEY ("libraryId") REFERENCES "Library"("id") ON DELETE CASCADE ON UPDATE CASCADE;

0 commit comments

Comments
 (0)