Skip to content

Instantly share code, notes, and snippets.

@learyjk
Last active December 19, 2024 23:51
Show Gist options
  • Save learyjk/0b9bef92c3fd31f0b85a1beb07b3e1ba to your computer and use it in GitHub Desktop.
Save learyjk/0b9bef92c3fd31f0b85a1beb07b3e1ba to your computer and use it in GitHub Desktop.
app.get(
'/dashboard/sso',
middleware.checkForUserObject,
// @ts-expect-error - TS7006 - Parameter 'req' implicitly has an 'any' type. | TS7006 - Parameter 'res' implicitly has an 'any' type. | TS7006 - Parameter 'next' implicitly has an 'any' type.
// eslint-disable-next-line unused-imports/no-unused-vars
function dashboardGetSso(req, res, next) {
const payload = {
iat: Math.ceil(new Date().getTime() / 1000),
jti: uuid.v4(),
first_name: req.user.firstName,
last_name: req.user.lastName ? req.user.lastName : '',
email: req.user.email,
} as const;
// eslint-disable-next-line no-var
var signedPayload = jwt.sign(payload, config.certiverse.secretCertiverse);
// eslint-disable-next-line no-var
var redirect =
'https://webflow.certiverse.com/auth/jwt/callback?jwt=' + signedPayload; // I made this up.
// eslint-disable-next-line no-var
var query = req.query;
if (query.return_to) {
redirect += '&return_to=' + encodeURIComponent(query.return_to);
}
return res.redirect(redirect);
}
);
// Example JWT
/*
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MzQ2NTIyNjAsImp0aSI6IjQ2MmU4OTQwLTdjZTYtNGY1NS04MmY0LWNmOTM2YTFkZWU5NCIsImZpcnN0X25hbWUiOiJLZWVnYW4iLCJsYXN0X25hbWUiOiJMZWFyeSIsImVtYWlsIjoia2VlZ2FuLmxlYXJ5QHdlYmZsb3cuY29tIn0.HSQuZ5CF20ov4BzfUNW4EzTacO4W4ZikW4Tgphs7sAQ
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment