Started work on Remember Me Tokens.
This commit is contained in:
parent
7f6abdf8e2
commit
895a8201a5
2 changed files with 124 additions and 0 deletions
|
|
@ -21,6 +21,7 @@ const config = require('../../config.json');
|
|||
const crypto = require('node:crypto');
|
||||
|
||||
//NPM Imports
|
||||
const argon2 = require('argon2');
|
||||
const bcrypt = require('bcrypt');
|
||||
|
||||
/**
|
||||
|
|
@ -69,4 +70,24 @@ module.exports.hashIP = function(ip){
|
|||
|
||||
//return the IP hash as a string
|
||||
return hashObj.digest('hex');
|
||||
}
|
||||
|
||||
/**
|
||||
* Site-wide remember-me token hashing function
|
||||
* @param {String} token - Token to hash
|
||||
* @returns {String} - Hashed token
|
||||
*/
|
||||
module.exports.hashRememberMeToken = async function(token){
|
||||
return await argon2.hash(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Site-wide remember-me token hash comparison function
|
||||
* @param {String} token - Token to compare
|
||||
* @param {String} hash - Hash to compare
|
||||
* @returns {String} - Comparison results
|
||||
*/
|
||||
module.exports.compareRememberMeToken = async function(token, hash){
|
||||
//Compare hash and return result
|
||||
return await argon2.verify(hash, token);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue