Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backend] Send email links to Host header #571

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/backend/user/src/resetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@

const subject = "MartletPlace - Reset your password";
const token = create_token({ userId: userId }, "/api/user/update-password");
const host = req.headers.host || "localhost";

Check failure on line 33 in apps/backend/user/src/resetPassword.ts

View workflow job for this annotation

GitHub Actions / Test (user)

tests/resetpassword.test.ts > Reset Password Endpoint > should send a reset password email successfully

TypeError: Cannot read properties of undefined (reading 'host') ❯ Module.resetPassword src/resetPassword.ts:33:28 ❯ tests/resetpassword.test.ts:36:5

Check failure on line 33 in apps/backend/user/src/resetPassword.ts

View workflow job for this annotation

GitHub Actions / Test (user)

tests/resetpassword.test.ts > Reset Password Endpoint > should return an error if email sending fails

TypeError: Cannot read properties of undefined (reading 'host') ❯ Module.resetPassword src/resetPassword.ts:33:28 ❯ tests/resetpassword.test.ts:136:5
const body = `
<p>Please click the link below to reset your password</p>
<a href="http://localhost/create-new-password/${token}"> Reset Password </a>
<a href="http://${host}/create-new-password/${token}"> Reset Password </a>
`;

try {
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/user/src/sendConfirmationEmail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@

const subject = "MartletPlace - Please confirm your email";
const token = create_token({ userId: userId }, "/api/user/confirm-email");
const host = req.headers.host || "localhost";

Check failure on line 33 in apps/backend/user/src/sendConfirmationEmail.ts

View workflow job for this annotation

GitHub Actions / Test (user)

tests/sendComfirmationEmail.test.ts > Send Confirmation Email Endpoint > should send a confirmation email successfully

TypeError: Cannot read properties of undefined (reading 'host') ❯ Module.sendConfirmationEmail src/sendConfirmationEmail.ts:33:28 ❯ tests/sendComfirmationEmail.test.ts:37:5

Check failure on line 33 in apps/backend/user/src/sendConfirmationEmail.ts

View workflow job for this annotation

GitHub Actions / Test (user)

tests/sendComfirmationEmail.test.ts > Send Confirmation Email Endpoint > should return an error if email sending fails

TypeError: Cannot read properties of undefined (reading 'host') ❯ Module.sendConfirmationEmail src/sendConfirmationEmail.ts:33:28 ❯ tests/sendComfirmationEmail.test.ts:129:5
const body = `
<p>Please click the link below to confirm your email</p>
<a href="http://localhost/confirm/${token}"> Confirm Email </a>
<a href="http://${host}/confirm/${token}"> Confirm Email </a>
`;

try {
Expand Down
Loading