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

Feat(user): Invite expiration fix #6758

Merged
merged 5 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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/breezy-clocks-applaud.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/user": patch
---

feat(user): invite expiry fix
6 changes: 1 addition & 5 deletions packages/user/src/services/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type InjectedDependencies = {
}

// 1 day
const DEFAULT_VALID_INVITE_DURATION = 60 * 60 * 24
const DEFAULT_VALID_INVITE_DURATION = 60 * 60 * 24 * 1000

export default class InviteService<
TEntity extends Invite = Invite
Expand Down Expand Up @@ -151,9 +151,6 @@ export default class InviteService<

private generateToken(data: any): string {
const jwtSecret: string = this.getOption("jwt_secret")
const expiresIn: number =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Do we not want to have support for configuring the duration?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially removed this since we're validating the invite expiration anyways, but I'll re-add it 😄

parseInt(this.getOption("valid_duration")) ||
DEFAULT_VALID_INVITE_DURATION

if (!jwtSecret) {
throw new MedusaError(
Expand All @@ -163,7 +160,6 @@ export default class InviteService<
}

return jwt.sign(data, jwtSecret, {
expiresIn,
jwtid: crypto.randomUUID(),
})
}
Expand Down
Loading