Skip to content

Instantly share code, notes, and snippets.

@Ratstail91
Created June 24, 2019 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ratstail91/b5b7519a1d3fb25d68010c88fb906472 to your computer and use it in GitHub Desktop.
Save Ratstail91/b5b7519a1d3fb25d68010c88fb906472 to your computer and use it in GitHub Desktop.
Literally all of my functions look like this!
const validateTokenCredentials = (connection) => (fields) => new Promise( (resolve, reject) => {
const validateQuery = 'SELECT COUNT(*) AS total FROM sessions WHERE sessions.accountId = ? AND sessions.token = ?;';
return connection.query(validateQuery, [fields.id, fields.token])
.then(results => results[0].total > 0 ? resolve(fields) : reject({msg: 'Invalid password change credentials', extra: [fields.id, fields.token]}))
;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment