Feat: Hash metrics password (#1778)

hash the metrics password

if it is not already hashed
This commit is contained in:
Bernd Storath
2025-03-31 09:58:02 +02:00
committed by GitHub
parent 940edb2b0c
commit 6e0d758e36
6 changed files with 52 additions and 11 deletions
@@ -107,7 +107,15 @@ export class GeneralService {
};
}
update(data: GeneralUpdateType) {
async update(data: GeneralUpdateType) {
// only hash the password if it is not already hashed
if (
data.metricsPassword !== null &&
!isValidPasswordHash(data.metricsPassword)
) {
data.metricsPassword = await hashPassword(data.metricsPassword);
}
return this.#db.update(general).set(data).execute();
}
@@ -11,7 +11,6 @@ const metricsEnabled = z.boolean({ message: t('zod.general.metricsEnabled') });
const metricsPassword = z
.string({ message: t('zod.general.metricsPassword') })
.min(1, { message: t('zod.general.metricsPassword') })
// TODO?: validate argon2 regex
.nullable();
export const GeneralUpdateSchema = z.object({