1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:19:30 +00:00

Implemented PasswordReset hashToken

This commit is contained in:
2022-02-14 00:22:25 +00:00
parent e644ba25bd
commit 3e581b689e

View File

@@ -1,5 +1,8 @@
'use strict';
const bcrypt = require('bcrypt');
const crypto = require('crypto');
const DatabaseConnectionPool = require('./DatabaseConnectionPool');
class PasswordReset {
@@ -35,8 +38,16 @@ class PasswordReset {
}
static hashToken(password) {
static async hashToken(u) {
const nonce = crypto
.randomBytes(16)
.toString('hex')
.slice(0, 16);
const tokenString = u.id + u.email + nonce + u.lastName;
const token = await bcrypt.hash(tokenString, 10);
return [ nonce, token ];
}
static generatePasswordReset() {