generated from lighthouse-labs/node-skeleton
-
Notifications
You must be signed in to change notification settings - Fork 1
/
helperfunctions.js
29 lines (26 loc) · 880 Bytes
/
helperfunctions.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const{ getUsers } = require('./db/queries/users.js');
// function to generate random string of 6 characters for user id
const generateCustomPassword = function() {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
let counter = 0;
while (counter < 7) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
counter += 1;
}
return result;
};
// *** refactor this to use sql query and check if user exists in database
const userLookup = function(key, value) {
const gettingUsers = getUsers().then(data => {
return data
});
console.log('is this the console.log', gettingUsers);
// for (let i in users) {
// if (users[i][key] === value) {
// return users[i];
// }
// }
return null;
};
module.exports = { copyToClipboard, generateRandomString, userLookup };