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.
This commit is contained in:
Simon Larsen
2024-05-29 15:45:48 +01:00
parent d0ace48aeb
commit c6efe40f3b
2 changed files with 14 additions and 0 deletions

View File

@@ -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!,

View File

@@ -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,