Refactor ActiveDirectory authentication strategy
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -7,7 +7,7 @@ const { getUserData } = require('../Middlewares/watcherMiddleware');
|
|||||||
const setupFilePath = path.join('setup.json');
|
const setupFilePath = path.join('setup.json');
|
||||||
const setupData = JSON.parse(fs.readFileSync(setupFilePath, 'utf-8'));
|
const setupData = JSON.parse(fs.readFileSync(setupFilePath, 'utf-8'));
|
||||||
|
|
||||||
passport.use(new ActiveDirectoryStrategy({
|
passport.use('ActiveDirectory', new ActiveDirectoryStrategy({
|
||||||
integrated: false,
|
integrated: false,
|
||||||
ldap: {
|
ldap: {
|
||||||
url: setupData.ldap.url,
|
url: setupData.ldap.url,
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ router.get('/logout', (req, res) => {
|
|||||||
var opts = { failWithError: true }
|
var opts = { failWithError: true }
|
||||||
|
|
||||||
router.post('/activedirectory', (req, res, next) => {
|
router.post('/activedirectory', (req, res, next) => {
|
||||||
passport.authenticate('ActiveDirectory', opts, (err, user, info) => {
|
passport.authenticate('ActiveDirectory', (err, user) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
return res.render('AuthLogin', { isAuthenticated: false, errorMessage: err.message, setupData: {}, showActiveDirectoryForm: true, currentUrl: req.originalUrl });
|
return res.render('AuthLogin', { isAuthenticated: false, errorMessage: err.message, setupData: {}, showActiveDirectoryForm: true, currentUrl: req.originalUrl });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user