You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
853 B
JavaScript
39 lines
853 B
JavaScript
module.exports = {
|
|
async fn() {
|
|
const { accessToken, currentUser } = this.req;
|
|
|
|
const session = await Session.updateOne({
|
|
accessToken,
|
|
deletedAt: null,
|
|
}).set({
|
|
deletedAt: new Date().toUTCString(),
|
|
});
|
|
|
|
const result = {
|
|
item: accessToken,
|
|
};
|
|
|
|
if (currentUser.ssoId) {
|
|
try {
|
|
const { sp, idp } = await sails.helpers.saml.getConfig(currentUser.ssoId);
|
|
|
|
const ssoUrl = await new Promise((resolve, reject) => {
|
|
sp.create_logout_request_url(idp, { session_index: session.sso_id }, (err, url) => {
|
|
if (err) {
|
|
reject();
|
|
} else {
|
|
resolve(url);
|
|
}
|
|
});
|
|
});
|
|
|
|
Object.assign(result, { ssoUrl });
|
|
} catch (e) {
|
|
// not saml or bad config
|
|
}
|
|
}
|
|
|
|
return result;
|
|
},
|
|
};
|