Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * @Author: Adam Eaton
- * @Date: 2017-07-19 16:05:29
- * @Last Modified by: Adam Eaton
- * @Last Modified time: 2017-07-19 16:10:41
- */
- // Define authen to use a callback function
- function authen(user, pass, cb) {
- ad.authenticate(user, pass, (err, auth) => {
- if (err) {
- console.log('ERROR: ' + JSON.stringify(err));
- } else if (auth) {
- console.log('Authenticated');
- } else {
- console.log('Authentication Failed');
- }
- cb(auth); // Pass auth to callback
- });
- }
- // Use authen in Route
- app.post('/login', (req, res) => {
- let user = req.body.user + '@mbsbooks.com';
- let pass = req.body.pass;
- ad.authen(user, pass, (auth) => {
- if (auth) { // Successful Login
- res.sendFile('./public/html/initial.html');
- } else { // Unsuccessful Login
- res.sendFile('./public/html/login.html');
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement