mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 22:39:26 +00:00
Implemented PasswordReset hashToken
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user