Browse Source

FB: using crypto.randomBytes instead of crypto.createHash

kaori 4 years ago
parent
commit
6acb560d78
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/server/models/password-reset-order.js

+ 4 - 2
src/server/models/password-reset-order.js

@@ -16,8 +16,10 @@ schema.plugin(uniqueValidator);
 class PasswordResetOrder {
 
   static generateOneTimeToken() {
-    const hasher = crypto.createHash('sha384');
-    const token = hasher.update((new Date()).getTime().toString()).digest('base64');
+
+    const buf = crypto.randomBytes(256);
+    const token = buf.toString('hex');
+
     return token;
   }