From bab4435345a2573fcfc098441c15f159a8147cb6 Mon Sep 17 00:00:00 2001 From: suhjae Date: Mon, 3 Feb 2025 19:36:35 +0900 Subject: [PATCH 1/3] feat: basic auth system --- app.config.ts | 6 +-- app.vue | 5 -- layouts/default.vue | 71 +++++++++++++++++++++++++++ nuxt.config.ts | 13 +++++ package.json | 4 +- pages/auth.vue | 35 ++++++++++++++ pages/confirm.vue | 18 +++++++ pages/dashboard.vue | 60 +++++++++++++++++++++++ pnpm-lock.yaml | 114 ++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 317 insertions(+), 9 deletions(-) create mode 100644 pages/auth.vue create mode 100644 pages/confirm.vue create mode 100644 pages/dashboard.vue diff --git a/app.config.ts b/app.config.ts index 6d15549..51588ec 100644 --- a/app.config.ts +++ b/app.config.ts @@ -53,10 +53,10 @@ export default defineAppConfig({ primary: "text-primary-500 hover:bg-primary-50 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500", white: - "text-gray-900 hover:bg-white focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500", - gray: "text-gray-700 hover:bg-gray-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-gray-500", + "text-gray-900 hover:bg-white focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500 hover:bg-gray-50", + gray: "text-gray-700 hover:bg-gray-100 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-gray-500, hover:bg-gray-50", black: - "text-gray-900 hover:bg-gray-900 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500", + "text-gray-900 hover:bg-gray-900 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-primary-500 hover:bg-gray-800", }, link: { primary: diff --git a/app.vue b/app.vue index a7b449e..9e3c110 100644 --- a/app.vue +++ b/app.vue @@ -33,11 +33,6 @@ const isDark = computed({ }, }); -const route = useRoute(); -const router = useRouter(); -const { locale, availableLocales } = useI18n(); -const lang = ref(route.query.lang as string); - const head = useLocaleHead({ addDirAttribute: true, identifierAttribute: "id", diff --git a/layouts/default.vue b/layouts/default.vue index 45f7278..03e0dfc 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -4,6 +4,15 @@ import LangSwitcher from "~/components/LangSwitcher.vue"; const { toggleContentSearch } = useUIState(); const { t } = useI18n(); const localePath = useLocalePath(); +const supabase = useSupabaseClient(); +const user = useSupabaseUser(); + +const signOut = async () => { + const { error } = await supabase.auth.signOut(); + if (error) console.log(error); + console.log("Signed out"); + navigateTo(localePath("/auth")); +}; const { data: navigation } = await useAsyncData("navigation", () => fetchContentNavigation() @@ -32,8 +41,34 @@ const links = computed(() => [ }, ]); +const items = [ + [ + { + slot: "account", + label: user?.value?.user_metadata.full_name, + disabled: true, + }, + ], + [ + { + label: "Dashboard", + icon: "i-ph-speedometer", + to: localePath("/dashboard"), + }, + ], + [ + { + label: "Sign out", + icon: "i-ph-arrow-line-up-right", + click: signOut, + color: "red", + }, + ], +]; + provide("navigation", navigation); provide("files", files); +provide("signOut", signOut); diff --git a/components/AppHeader.vue b/components/AppHeader.vue new file mode 100644 index 0000000..c93e093 --- /dev/null +++ b/components/AppHeader.vue @@ -0,0 +1,115 @@ + + + diff --git a/layouts/dashboard.vue b/layouts/dashboard.vue new file mode 100644 index 0000000..b037ea8 --- /dev/null +++ b/layouts/dashboard.vue @@ -0,0 +1,51 @@ + + + diff --git a/layouts/default.vue b/layouts/default.vue index 03e0dfc..9a80d92 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -1,155 +1,13 @@ - - -
- -

Dashboard

- -

Welcome, {{ user?.user_metadata.full_name }}

- -
- Sign Out -
-
-
-
diff --git a/pages/dashboard/result.vue b/pages/dashboard/result.vue new file mode 100644 index 0000000..ef417cf --- /dev/null +++ b/pages/dashboard/result.vue @@ -0,0 +1 @@ + From 0f2221301af39bfd00683821292a0f3edcb9a364 Mon Sep 17 00:00:00 2001 From: suhjae Date: Tue, 4 Feb 2025 13:06:00 +0900 Subject: [PATCH 3/3] feat: basic account system --- app.vue | 1 - components/AppHeader.vue | 48 +++++---- layouts/dashboard.vue | 50 +++------- layouts/default.vue | 6 +- locales/en/main.json | 56 ++++++++++- package.json | 1 + pages/auth.vue | 10 +- pages/dashboard/index.vue | 78 ++------------- pages/dashboard/result.vue | 8 +- pages/dashboard/settings/index.vue | 150 +++++++++++++++++++++++++++++ pnpm-lock.yaml | 10 ++ 11 files changed, 283 insertions(+), 135 deletions(-) create mode 100644 pages/dashboard/settings/index.vue diff --git a/app.vue b/app.vue index 089d531..90024f3 100644 --- a/app.vue +++ b/app.vue @@ -47,7 +47,6 @@ const head = useLocaleHead({ const signOut = async () => { const { error } = await supabase.auth.signOut(); if (error) console.log(error); - console.log("Signed out"); navigateTo(localePath("/auth")); }; diff --git a/components/AppHeader.vue b/components/AppHeader.vue index c93e093..6a48489 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -18,14 +18,14 @@ const items = [ ], [ { - label: "Dashboard", + label: t("nav.account.dashboard"), icon: "i-ph-speedometer", to: localePath("/dashboard"), }, ], [ { - label: "Sign out", + label: t("nav.account.signOut"), icon: "i-ph-arrow-line-up-right", click: signOut, color: "red", @@ -44,40 +44,40 @@ const items = [