User can signup / signin (WIP)

This commit is contained in:
ChatonDeAru
2024-09-14 01:40:55 +02:00
committed by ChatonDeAru (Romain)
parent c35de52aec
commit 37b2238b84
16 changed files with 663 additions and 365 deletions

View File

@@ -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<string | undefined>) => {
// 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<Partial<ZxcvbnResult>>({
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,
}
}