Skip to content

Instantly share code, notes, and snippets.

@rnavagamuwa
Created February 28, 2018 09:40
Show Gist options
  • Save rnavagamuwa/f3f219dd3e7899934e863e6e298b261e to your computer and use it in GitHub Desktop.
Save rnavagamuwa/f3f219dd3e7899934e863e6e298b261e to your computer and use it in GitHub Desktop.
let AWS = require('aws-sdk');
let connectionManager = require('./ConnectionManager');
let SL = require('@slappforge/slappforge-sdk');
const rds = new SL.AWS.RDS(connectionManager);
exports.handler = function (event, context, callback) {
let successfullyLoggedIn = false;
// Replace the query with the actual query
// You can pass the existing connection to this function.
// A new connection will be created if it's not present as the third param
// You must always end the DB connection after it's used
rds.query({
instanceIdentifier: 'authDatabase',
query: 'SELECT * FROM users WHERE Email = ? AND Password = ?',
inserts: [event.email, event.password]
}, function (error, results, connection) {
if (error) {
throw error;
} else {
successfullyLoggedIn = results.length > 0;
}
connection.end();
callback(null, successfullyLoggedIn);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment