Created
February 28, 2018 09:40
-
-
Save rnavagamuwa/f3f219dd3e7899934e863e6e298b261e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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