Skip to content
Permalink
c95f2737f1
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
32 lines (27 sloc) 906 Bytes
// pg DB connection from config file /helpers/db.js
const db = require('../helpers/db.js')
const bcrypt = require('bcrypt');
exports.getUsername = async function getUsername(login) {
let username = await db.query('SELECT username FROM users WHERE username =$1;', login)
.then(username => {
return username
});
return username;
}
exports.compareSecret = async function compareSecret(secret, hash) { // updated
let compare = await bcrypt.compare(secret, hash)
.then(compare => {
return compare
});
return compare
}
exports.getLoginData = async function getLoginData(login) {
let loginData = await db.query('SELECT username,password FROM users WHERE username =$1;', login)
.then(loginData => {
return {
username: loginData[0].username,
passwordhash: loginData[0].password
}
});
return loginData
}