Refactor rendering code in SSO.ts

This commit is contained in:
Simon Larsen
2023-12-25 15:04:27 +00:00
parent 8a0b977a17
commit e57963cad1

View File

@@ -265,11 +265,16 @@ router.post(
alreadySavedUser
);
return Response.render(req, res, '/usr/src/app/FeatureSet/Identity/Views/Message.ejs', {
title: 'Email not verified.',
message:
'Email is not verified. We have sent you an email with the verification link. Please do not forget to check spam.',
});
return Response.render(
req,
res,
'/usr/src/app/FeatureSet/Identity/Views/Message.ejs',
{
title: 'Email not verified.',
message:
'Email is not verified. We have sent you an email with the verification link. Please do not forget to check spam.',
}
);
}
// check if the user already belongs to the project
@@ -290,11 +295,16 @@ router.post(
// user not in project, add him to default teams.
if (!projectSSO.teams || projectSSO.teams.length === 0) {
return Response.render(req, res, '/usr/src/app/FeatureSet/Identity/Views/Message.ejs', {
title: 'No teams added.',
message:
'No teams have been added to this SSO config. Please contact your admin and have default teams added.',
});
return Response.render(
req,
res,
'/usr/src/app/FeatureSet/Identity/Views/Message.ejs',
{
title: 'No teams added.',
message:
'No teams have been added to this SSO config. Please contact your admin and have default teams added.',
}
);
}
for (const team of projectSSO.teams) {
@@ -320,13 +330,18 @@ router.post(
}
if (isNewUser) {
return Response.render(req, res, '/usr/src/app/FeatureSet/Identity/Views/Message.ejs', {
title: 'You have not signed up so far.',
message:
'You need to sign up for an account on OneUptime with this email:' +
email.toString() +
'. Once you have signed up, you can use SSO to log in to your project.',
});
return Response.render(
req,
res,
'/usr/src/app/FeatureSet/Identity/Views/Message.ejs',
{
title: 'You have not signed up so far.',
message:
'You need to sign up for an account on OneUptime with this email:' +
email.toString() +
'. Once you have signed up, you can use SSO to log in to your project.',
}
);
}
const projectId: ObjectID = new ObjectID(