replace String.random with randomstring

This commit is contained in:
undefined committed 2025-06-30 16:24:35 +08:00
1 parent b18cce3f66
commit 5d7f5fef38
22 files changed
+64 -48

No files matched your search

+3 -3
View File
@@ -12,7 +12,7 @@ import pwhash from '../lib/hash.hydro';
import bus from '../service/bus';
import db from '../service/db';
import { Value } from '../typeutils';
import { ArgMethod, buildProjection } from '../utils';
import { ArgMethod, buildProjection, randomstring } from '../utils';
import { PERM, PRIV } from './builtin';
import domain from './domain';
import * as setting from './setting';
@@ -285,7 +285,7 @@ class UserModel {
@ArgMethod
static async setPassword(uid: number, password: string): Promise<Udoc> {
const salt = String.random();
const salt = randomstring();
const res = await coll.findOneAndUpdate(
{ _id: uid },
{ $set: { salt, hash: await pwhash(password, salt), hashType: 'hydro' } },
@@ -317,7 +317,7 @@ class UserModel {
uid = Math.max((udoc?._id || 0) + 1, 2);
autoAlloc = true;
}
const salt = String.random();
const salt = randomstring();
while (true) {
try {
// eslint-disable-next-line no-await-in-loop