mirror of
https://github.com/Paris-est-Ludique/ForceOrange.git
synced 2025-09-10 22:26:27 +02:00
✨ User can signup / signin (WIP)
This commit is contained in:
committed by
ChatonDeAru (Romain)
parent
c35de52aec
commit
37b2238b84
42
modules/app/composables/passwordStrength.ts
Normal file
42
modules/app/composables/passwordStrength.ts
Normal 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,
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user