Open froyoga opened 2 years ago
@froyoga The userContext
object can be undefined
when the user is not authenticated. We can improve the logout
method to not crash when the userContext is not available.
Before the fix is released, can you check req.userContext
in your application code as a workaround?
Internal Ref: OKTA-436562
Yeah, I was thinking that's what I'll have to do. Here's my entire route method, where I log out locally and then attempt to log out of Okta:
app.get("/session-logout", (req: Request, res: Response, next: NextFunction) => {
try {
if (req.session) {
req.session.destroy((err) => {
if (err) {
return next(createError(400, "Unable to logout."));
}
});
}
if ((req as any).userContext) {
req.url = "/logout";
req.method = "POST";
return app._router.handle(req, res, next)
} else {
return res.redirect("/");
}
} catch (err) {
return next(createError(500, err.message));
}
});
I'm submitting this issue for the package(s):
I'm submitting a:
Current behavior
I am calling the oidc-middleware autogenerated endpoint
/logout
when this occurs. It doesn't always happen, so I'm able to log out fine most of the time. However, when it does happen my app completely crashes.Expected behavior
I would be able to log out successfully and my app doesn't crash
Minimal reproduction of the problem with instructions
Extra information about the use case/user story you are trying to implement
Environment
node -v
): v16.0.0