Skip to content

Commit

Permalink
feat: support dynamic password reset url
Browse files Browse the repository at this point in the history
Signed-off-by: tedraykov <[email protected]>
  • Loading branch information
tedraykov committed May 15, 2023
1 parent ecb8ef6 commit cd2f570
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit cd2f570

Please sign in to comment.