From 37b2238b84f0a96c97ff4202f1eef9e69b591838 Mon Sep 17 00:00:00 2001 From: ChatonDeAru <823314+chatondearu@users.noreply.github.com> Date: Sat, 14 Sep 2024 01:40:55 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20User=20can=20signup=20/=20signin=20?= =?UTF-8?q?(WIP)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/app/README.md | 12 +- modules/app/components/FOHeader.vue | 42 ++ modules/app/components/PasswordStrength.vue | 41 ++ modules/app/composables/passwordStrength.ts | 42 ++ modules/app/layouts/default.vue | 21 +- modules/app/middleware/auth.ts | 7 + modules/app/netlify.toml | 18 +- modules/app/nuxt.config.ts | 2 +- modules/app/package.json | 4 + modules/app/pages/join/index.vue | 44 +- modules/app/pages/signin/confirm.vue | 27 + modules/app/pages/signin/index.vue | 39 +- modules/supabase/README.md | 7 + modules/supabase/package.json | 14 + modules/supabase/types.ts | 187 +++++++ pnpm-lock.yaml | 521 ++++++++------------ 16 files changed, 663 insertions(+), 365 deletions(-) create mode 100644 modules/app/components/FOHeader.vue create mode 100644 modules/app/components/PasswordStrength.vue create mode 100644 modules/app/composables/passwordStrength.ts create mode 100644 modules/app/middleware/auth.ts create mode 100644 modules/app/pages/signin/confirm.vue create mode 100644 modules/supabase/README.md create mode 100644 modules/supabase/package.json create mode 100644 modules/supabase/types.ts diff --git a/modules/app/README.md b/modules/app/README.md index f5db2a2..0529770 100644 --- a/modules/app/README.md +++ b/modules/app/README.md @@ -1,6 +1,10 @@ -# Nuxt 3 Minimal Starter +[![Netlify Status](https://api.netlify.com/api/v1/badges/bcf66326-b808-4ffd-9018-fb24315fce5f/deploy-status)](https://app.netlify.com/sites/force-orange/deploys) -Look at the [Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to learn more. +# Nuxt + +Look at the +[Nuxt 3 documentation](https://nuxt.com/docs/getting-started/introduction) to +learn more. ## Setup @@ -72,4 +76,6 @@ yarn preview bun run preview ``` -Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information. +Check out the +[deployment documentation](https://nuxt.com/docs/getting-started/deployment) for +more information. diff --git a/modules/app/components/FOHeader.vue b/modules/app/components/FOHeader.vue new file mode 100644 index 0000000..6bc7f8b --- /dev/null +++ b/modules/app/components/FOHeader.vue @@ -0,0 +1,42 @@ + + + \ No newline at end of file diff --git a/modules/app/components/PasswordStrength.vue b/modules/app/components/PasswordStrength.vue new file mode 100644 index 0000000..2c05201 --- /dev/null +++ b/modules/app/components/PasswordStrength.vue @@ -0,0 +1,41 @@ + + + \ No newline at end of file diff --git a/modules/app/composables/passwordStrength.ts b/modules/app/composables/passwordStrength.ts new file mode 100644 index 0000000..128f941 --- /dev/null +++ b/modules/app/composables/passwordStrength.ts @@ -0,0 +1,42 @@ +import { zxcvbn, zxcvbnOptions, type ZxcvbnResult } from '@zxcvbn-ts/core' +import * as zxcvbnCommonPackage from '@zxcvbn-ts/language-common' +import * as zxcvbnEnPackage from '@zxcvbn-ts/language-fr' + +export const usePasswordStrength = (password: Ref) => { + + // 0 # too guessable: risky password. (guesses < 10 ^ 3) + // 1 # very guessable: protection from throttled online attacks. (guesses < 10 ^ 6) + // 2 # somewhat guessable: protection from unthrottled online attacks. (guesses < 10 ^ 8) + // 3 # safely unguessable: moderate protection from offline slow - hash scenario. (guesses < 10 ^ 10) + // 4 # very unguessable: strong protection from offline slow - hash scenario. (guesses >= 10 ^ 10) + + const strength = ref>({ + score: 0, + }) + + const options = { + translations: zxcvbnEnPackage.translations, + graphs: zxcvbnCommonPackage.adjacencyGraphs, + dictionary: { + ...zxcvbnCommonPackage.dictionary, + ...zxcvbnEnPackage.dictionary, + }, + } + + zxcvbnOptions.setOptions(options) + + watchDebounced(password, (newPassword) => { + if (!newPassword) { + strength.value = { + score: 0, + } + return + } + + strength.value = zxcvbn(newPassword.trim()) + }, { immediate: true, debounce: 500 }) + + return { + strength, + } +} \ No newline at end of file diff --git a/modules/app/layouts/default.vue b/modules/app/layouts/default.vue index 9995ce6..c7f8af1 100644 --- a/modules/app/layouts/default.vue +++ b/modules/app/layouts/default.vue @@ -1,30 +1,13 @@