From 64e4037b399d55b107f7758a9ac9bb3be6313970 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 12 Feb 2024 21:52:21 +0100 Subject: [PATCH] remove google account details on unlink --- src/controllers/calendarController.ts | 14 ++++++++++++++ src/models/user.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/controllers/calendarController.ts b/src/controllers/calendarController.ts index 44efca0..faefee9 100644 --- a/src/controllers/calendarController.ts +++ b/src/controllers/calendarController.ts @@ -420,6 +420,20 @@ export async function UnlinkGoogleCalendar(req: Request, res: Response) { userId: userSession.user_id, }); + // set user google account data to null + + await User.update( + { + google_account_name: "", + google_account_picture: "", + }, + { + where: { + user_id: userSession.user_id, + }, + } + ); + res.status(200).send({ msg: "success" }); } catch (error) { logger.error(error); diff --git a/src/models/user.ts b/src/models/user.ts index b346b58..36638d0 100644 --- a/src/models/user.ts +++ b/src/models/user.ts @@ -93,7 +93,7 @@ User.init( }, google_account_picture: { type: DataTypes.STRING, - allowNull: true, + allowNull: true, // varchar(1050) needs to be set manually }, analytics_enabled: { type: DataTypes.BOOLEAN,