Brylie Christopher Oxley
Brylie Christopher Oxley

Reputation: 1872

Override or disable DEFAULT_PASSWORD_ENROLL_TOKEN_EXPIRATION_DAYS?

We are sending out account invitation messages to users, using Accounts.sendEnrollmentEmail. In some cases, users fail to click the link for some time. In those cases, we have to re-send the invitations, making extra work for admin users.

The Meteor Accounts package seems to use DEFAULT_PASSWORD_ENROLL_TOKEN_EXPIRATION_DAYS to expire activation links. Is it possible to override this value or disable it?

Upvotes: 1

Views: 65

Answers (2)

Brylie Christopher Oxley
Brylie Christopher Oxley

Reputation: 1872

We were able to fix the issue with the following, e.g. in accounts.js:

Accounts.config({
  passwordEnrollTokenExpirationInDays: 60
});

Upvotes: 0

Jankapunkt
Jankapunkt

Reputation: 8423

As I found in the code it is a const with a fixed value.

You therefore won't be able to override it by default.

However you still have some options here.

  1. Override the accounts-base package and use values from process.env or Meteor.settings for the expiration variable.

  2. Use additional token data in sendEnrollmentEmail and place a custom expiration date there. Then use onEnrollmentLink to make a custom validation of the expiration date.

  3. Use a custom Collection to store expiration dates and check them in onEnrollmentLink

If you prefer the first option it would be great if you also open a PR on the Meteor repo so others will benefit from it.

Upvotes: 1

Related Questions