From 4e7d5e7d65133e8e25ddb6f6a1ac82dac180c206 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 19 Jan 2022 11:22:44 +0000 Subject: [PATCH] Fix server crash when trying to log out and already logged out --- packages/worker/src/api/controllers/global/auth.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/worker/src/api/controllers/global/auth.js b/packages/worker/src/api/controllers/global/auth.js index 2ba12194ca..44ee99aee7 100644 --- a/packages/worker/src/api/controllers/global/auth.js +++ b/packages/worker/src/api/controllers/global/auth.js @@ -141,7 +141,9 @@ exports.resetUpdate = async ctx => { } exports.logout = async ctx => { - await platformLogout({ ctx, userId: ctx.user._id }) + if (ctx.user && ctx.user._id) { + await platformLogout({ ctx, userId: ctx.user._id }) + } ctx.body = { message: "User logged out." } }