diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..a8f8f16 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,22 @@ +{ + "recommendations": [ + "aaron-bond.better-comments", + "antfu.iconify", + "dbaeumer.vscode-eslint", + "editorconfig.editorconfig", + "github.copilot", + "github.copilot-chat", + "github.vscode-github-actions", + "ms-azuretools.vscode-docker", + "mtxr.sqltools", + "mtxr.sqltools-driver-pg", + "pflannery.vscode-versionlens", + "ritwickdey.liveserver", + "tamasfe.even-better-toml", + "visualstudioexptteam.intellicode-api-usage-examples", + "visualstudioexptteam.vscodeintellicode", + "vue.volar", + "vunguyentuan.vscode-css-variables", + "yoavbls.pretty-ts-errors" + ] +} diff --git a/app/composables/use-equipment-search.ts b/app/composables/use-equipment-search.ts index 18647da..4a00934 100644 --- a/app/composables/use-equipment-search.ts +++ b/app/composables/use-equipment-search.ts @@ -4,7 +4,7 @@ import type { EquipmentItem } from '~/components/equipment/EquipmentTable.vue'; interface EquipmentData { readonly id: string; readonly name: string | null; - readonly weight: number | null; + readonly weight: number; readonly createdAt: string; } diff --git a/app/middleware/0.user.global.ts b/app/middleware/0.user.global.ts index dfbb362..1939e76 100644 --- a/app/middleware/0.user.global.ts +++ b/app/middleware/0.user.global.ts @@ -1,4 +1,8 @@ -export default defineNuxtRouteMiddleware(async () => { +export default defineNuxtRouteMiddleware(async (to) => { + if (shouldSkipAuth(to)) { + return + } + if (import.meta.server) { const { getUser, user } = useUserStore() diff --git a/app/middleware/1.auth.global.ts b/app/middleware/1.auth.global.ts index ee8ae2f..134059e 100644 --- a/app/middleware/1.auth.global.ts +++ b/app/middleware/1.auth.global.ts @@ -1,6 +1,10 @@ import { startPagePath } from '~~/constants'; export default defineNuxtRouteMiddleware(async (to) => { + if (shouldSkipAuth(to)) { + return + } + const { isAuthenticated } = useUserStore() if (isAuthenticated.value && to.path === '/login') { diff --git a/app/models/oauth.ts b/app/models/oauth.ts new file mode 100644 index 0000000..77c3128 --- /dev/null +++ b/app/models/oauth.ts @@ -0,0 +1 @@ +export type OAuthProvider = 'twitch' diff --git a/app/models/twitch.ts b/app/models/twitch.ts new file mode 100644 index 0000000..bbe76e6 --- /dev/null +++ b/app/models/twitch.ts @@ -0,0 +1,25 @@ +export interface TwitchUser { + readonly id: string; + readonly login: string; + readonly display_name: string; + readonly type: '' | 'staff' | 'admin' | 'global_mod'; + readonly broadcaster_type: '' | 'affiliate' | 'partner'; + readonly description: string; + readonly profile_image_url: string; + readonly offline_image_url: string; + readonly created_at: string; + // "user:read:email" scope required + readonly email?: string; +} + +export interface TwitchOAuthTokenResponse { + readonly access_token: string; + readonly expires_in: number; + readonly refresh_token: string; + readonly token_type: string; + readonly scope?: string[]; +} + +export interface TwitchUsersResponse { + readonly data: TwitchUser[]; +} diff --git a/app/pages/auth/twitch.vue b/app/pages/auth/twitch.vue new file mode 100644 index 0000000..6b843e1 --- /dev/null +++ b/app/pages/auth/twitch.vue @@ -0,0 +1,109 @@ + + + + + diff --git a/app/pages/login.vue b/app/pages/login.vue index 05066c9..f9ca8d8 100644 --- a/app/pages/login.vue +++ b/app/pages/login.vue @@ -1,17 +1,21 @@