From fef4fa1e300480017cb48973e494520e467a252a Mon Sep 17 00:00:00 2001 From: Jesse Wierzbinski Date: Sat, 15 Jun 2024 20:34:35 -1000 Subject: [PATCH] feat: :recycle: Rewrite registration UI --- bun.lockb | Bin 674044 -> 674044 bytes components/inputs/checkbox.vue | 12 ++++ components/inputs/password.vue | 43 ++++++++++- composables/Instance.ts | 37 ++++++++++ package.json | 2 +- pages/oauth/authorize.vue | 4 +- pages/register/index2.vue | 126 +++++++++++++++++++++++++++------ utils/passwords.ts | 22 ++++++ 8 files changed, 221 insertions(+), 25 deletions(-) create mode 100644 components/inputs/checkbox.vue create mode 100644 utils/passwords.ts diff --git a/bun.lockb b/bun.lockb index 76ed7618b29705124f4214620f0f68d90b2ff0d6..aadea3905e07d3a096593a25a9b13698bee919d0 100755 GIT binary patch delta 174 zcmew}QS;A4%?Wx654SfK=gI0%Hj$MmH%)#t^xv%8-99IWkI9gRzJpD zJ<~IK7!BGZdKrP3X?sL3^WOxAhsPa`C$eaB@Z6H{W!(89cZzp(;=>uogyuYCaLqJK zXjW0He|q&dbNRCA4?NyYYf;(yR(p5W)2tMet5Ve)#FUHLr@mtbVwUYw-?4UWWwdBl aSi%Ox>_E)1U114ltTLm;_PXPob&UWZX-``K delta 173 zcmV;e08;<_ktzI=ohwKK{dOSsLm5S ztAVoDuFNeZetT2!QJw*KIZUe8y}X0JlI0 + + + + \ No newline at end of file diff --git a/components/inputs/password.vue b/components/inputs/password.vue index 1b16377..678b818 100644 --- a/components/inputs/password.vue +++ b/components/inputs/password.vue @@ -1,6 +1,16 @@ \ No newline at end of file + + + \ No newline at end of file diff --git a/utils/passwords.ts b/utils/passwords.ts new file mode 100644 index 0000000..8b86380 --- /dev/null +++ b/utils/passwords.ts @@ -0,0 +1,22 @@ +/** + * Get the strength of a password + * @param password The password to check + * @returns Number from 0 to Infinity representing the strength of the password + */ +export const passwordStrength = (password: string): number => { + const length = password.length; + const specialChars = password.match(/[^A-Za-z0-9]/g)?.length || 0; + const numbers = password.match(/[0-9]/g)?.length || 0; + const upperCase = password.match(/[A-Z]/g)?.length || 0; + const lowerCase = password.match(/[a-z]/g)?.length || 0; + + // Calculate the strength of the password + return ( + (length * 4 + + specialChars * 6 + + numbers * 4 + + upperCase * 2 + + lowerCase * 2) / + 16 + ); +};