Last active
December 19, 2017 22:02
-
-
Save nomoney4me/1da1d29e1697c4683e2845ef74d9d019 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 adConfig = { | |
url:'', | |
baseDN: '', | |
username: '', | |
password: '' | |
} | |
const ActiveDirectory = require('activedirectory2').promiseWrapper | |
, ad = new ActiveDirectory(adConfig) | |
module.exports = (params, callback) => { | |
ad.authenticate(params.username, params.password).then((auth) => { | |
if(auth) { | |
// establish a session using express-session | |
// return true | |
} | |
} | |
} |
This file contains hidden or 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
const express = require('express') | |
, app = express() | |
let isLogin = require('./controllers/isLogin.js') | |
app.use('/', isLogin, require('./routes/secureRoutes.js')()); |
This file contains hidden or 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
const adCheck = require('./adLogin') | |
module.exports = (req,res,next) => { | |
adCheck(req.body, (auth) => { | |
if(auth === true) next() | |
}) | |
} |
This file contains hidden or 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
const express = require('express') | |
, secureRouter = express.Router() | |
module.exports = () => { | |
secureRouter.get('/foo', (req, res) => { | |
res.json({ | |
foo:'bar' | |
}) | |
}); | |
secureRouter.get('/foo2', (req, res) => { | |
res.json({ | |
foo2:'bar2' | |
}) | |
}); | |
return secureRouter; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment