23 lines
786 B
JavaScript
23 lines
786 B
JavaScript
import { getConfig } from "../common/config.js";
|
|
|
|
export async function logout(req, res, next) {
|
|
const strategy = req.session.authStrategy ?`${req.session.authStrategy}` : null;
|
|
req.logout(function (err) {
|
|
if (err) { return next(err); }
|
|
req.session.destroy(function (err) {
|
|
if (err) { return next(err); }
|
|
if (strategy) {
|
|
const config = getConfig();
|
|
const strategyConfig = config.authModules[strategy];
|
|
if (strategyConfig && strategyConfig.logoutURL) {
|
|
res.redirect(strategyConfig.logoutURL);
|
|
} else {
|
|
res.redirect('/');
|
|
}
|
|
} else {
|
|
res.redirect('/');
|
|
}
|
|
});
|
|
});
|
|
}
|