From c6efe40f3bddb3a7594b9eaa4ed3cfd19e093715 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Wed, 29 May 2024 15:45:48 +0100 Subject: [PATCH] refactor: Add logging statements for user sign up, email verification, password reset, and login This code change adds logging statements for user sign up, email verification, password reset, and login in the Authentication.ts and SSO.ts files. The logging statements provide information about the corresponding user actions, including the user's email. This enhancement improves the visibility and monitoring of user activities in the system. --- App/FeatureSet/Identity/API/Authentication.ts | 12 ++++++++++++ App/FeatureSet/Identity/API/SSO.ts | 2 ++ 2 files changed, 14 insertions(+) diff --git a/App/FeatureSet/Identity/API/Authentication.ts b/App/FeatureSet/Identity/API/Authentication.ts index ea2d25d425..8b545e37c1 100644 --- a/App/FeatureSet/Identity/API/Authentication.ts +++ b/App/FeatureSet/Identity/API/Authentication.ts @@ -203,6 +203,8 @@ router.post( httpOnly: true, }); + logger.info('User signed up: ' + savedUser.email?.toString()); + return Response.sendEntityResponse(req, res, savedUser, User); } @@ -398,6 +400,8 @@ router.post( logger.error(err); }); + logger.info('User email verified: ' + user.email?.toString()); + return Response.sendEmptySuccessResponse(req, res); } catch (err) { return next(err); @@ -490,6 +494,10 @@ router.post( logger.error(err); }); + logger.info( + 'User password reset: ' + alreadySavedUser.email?.toString() + ); + return Response.sendEmptySuccessResponse(req, res); } catch (err) { return next(err); @@ -581,6 +589,10 @@ router.post( alreadySavedUser.password.toString() === user.password!.toString() ) { + logger.info( + 'User logged in: ' + alreadySavedUser.email?.toString() + ); + const token: string = JSONWebToken.signUserLoginToken({ tokenData: { userId: alreadySavedUser.id!, diff --git a/App/FeatureSet/Identity/API/SSO.ts b/App/FeatureSet/Identity/API/SSO.ts index 5031ca0f82..ee64605e34 100644 --- a/App/FeatureSet/Identity/API/SSO.ts +++ b/App/FeatureSet/Identity/API/SSO.ts @@ -449,6 +449,8 @@ const loginUserWithSso: LoginUserWithSsoFunction = async ( const host: Hostname = await DatabaseConfig.getHost(); const httpProtocol: Protocol = await DatabaseConfig.getHttpProtocol(); + logger.info('User logged in with SSO' + email.toString()); + return Response.redirect( req, res,