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

Support Dynamic Password Reset URL #6839

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/hip-owls-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reactioncommerce/api-plugin-authentication": minor
---

Allow dynamic password reset URL in the email
1 change: 1 addition & 0 deletions packages/api-plugin-authentication/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const { str } = envalid;
export default envalid.cleanEnv(
process.env,
{
PASSWORD_RESET_PATH_FRAGMENT: str({ default: "?resetToken=" }),
STORE_URL: str({ devDefault: "http://localhost:4000" }),
TOKEN_SECRET: str({ default: "UPDATE_THIS_SECRET" })
},
Expand Down
4 changes: 2 additions & 2 deletions packages/api-plugin-authentication/src/util/accountServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default async (app) => {
if (accountsServer && accountsGraphQL) {
return { accountsServer, accountsGraphQL };
}
const { MONGO_URL, STORE_URL, TOKEN_SECRET } = config;
const { MONGO_URL, PASSWORD_RESET_PATH_FRAGMENT, STORE_URL, TOKEN_SECRET } = config;
const { context } = app;

const client = await mongoConnectWithRetry(MONGO_URL);
Expand All @@ -38,7 +38,7 @@ export default async (app) => {
sendMail: async ({ to, text }) => {
const query = text.split("/");
const token = query[query.length - 1];
const url = `${STORE_URL}/?resetToken=${token}`;
const url = `${STORE_URL}/${PASSWORD_RESET_PATH_FRAGMENT}${token}`;
await context.mutations.sendResetAccountPasswordEmail(context, {
email: to,
url
Expand Down