summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-04-11 00:36:12 +1000
committerErkin Alp Güney <erkinalp9035@gmail.com>2022-04-10 17:39:23 +0300
commit12aed1db1ffadbcac4ed7cae68b6a6d8b88fa4cc (patch)
treeff17d1b1240806e1fefcbfcdee920f493efcc55c /api
parentUpdate Guild.ts (diff)
downloadserver-12aed1db1ffadbcac4ed7cae68b6a6d8b88fa4cc.tar.xz
Fix compile errors in checkPassword's entropy check
Diffstat (limited to 'api')
-rw-r--r--api/src/util/utility/passwordStrength.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/api/src/util/utility/passwordStrength.ts b/api/src/util/utility/passwordStrength.ts
index e75e48f6..f3960e48 100644
--- a/api/src/util/utility/passwordStrength.ts
+++ b/api/src/util/utility/passwordStrength.ts
@@ -46,15 +46,15 @@ export function checkPassword(password: string): number {
 		strength = 0;
 	}
 	
-	let entropyMap;
+	let entropyMap: { [key: string]: number } = {};
 	for (let i = 0; i < password.length; i++) {
 		if (entropyMap[password[i]]) entropyMap[password[i]]++;
 		else entropyMap[password[i]] = 1;
 	}
 	
-	let entropies = Array(entropyMap);
-		
+	let entropies = Object.values(entropyMap);
+	
 	entropies.map(x => (x / entropyMap.length));
-	strength += entropies.reduceRight((a, x), a - (x * Math.log2(x))) / Math.log2(password.length);	
+	strength += entropies.reduceRight((a: number, x: number) => a - (x * Math.log2(x))) / Math.log2(password.length);	
 	return strength;
 }