mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 06:07:21 +02:00
fix: preserve anonymous sessions during GitHub sign-in
This commit is contained in:
2 files changed
+90
-5
No files matched your search
@@ -264,11 +264,15 @@ export function handleError(
|
||||
|
||||
export async function getUser(req: express.Request) {
|
||||
function notConnected(): never {
|
||||
req.logout((error) => {
|
||||
if (error) {
|
||||
logger.error("logout failed", serializeError(error));
|
||||
}
|
||||
});
|
||||
// Anonymous sessions can hold an in-progress OAuth flow. Passport's
|
||||
// logout regenerates the session, so only clear an invalid identity.
|
||||
if (req.user) {
|
||||
req.logout((error) => {
|
||||
if (error) {
|
||||
logger.error("logout failed", serializeError(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
throw new AnonymousError("not_connected", {
|
||||
httpStatus: 401,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user