瀏覽代碼

FB: using crypto.randomBytes instead of crypto.createHash

kaori 4 年之前
父節點
當前提交
6acb560d78
共有 1 個文件被更改,包括 4 次插入2 次删除
  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;
   }