🥅 Catch error if incorrectly configured user

This commit is contained in:
Alicia Sykes 2022-02-12 21:29:08 +00:00
parent 04082763d3
commit fd99837b78
1 changed files with 4 additions and 0 deletions

View File

@ -39,6 +39,10 @@ const getUsers = () => {
* @returns {String} The hashed token
*/
const generateUserToken = (user) => {
if (!user.user || !user.hash) {
ErrorHandler('Invalid user object. Must have `user` and `hash` parameters');
return undefined;
}
const strAndUpper = (input) => input.toString().toUpperCase();
const sha = sha256(strAndUpper(user.user) + strAndUpper(user.hash));
return strAndUpper(sha);