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

[PM-12982] Bugfix - Fix incorrect handling of the first day of the next month is isCardExpired #11337

Merged
merged 1 commit into from
Sep 30, 2024
Merged
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
6 changes: 3 additions & 3 deletions libs/common/src/autofill/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ export function isCardExpired(cipherCard: CardView): boolean {

const parsedYear = parseInt(normalizedYear, 10);

// First day of the next month minus one, to get last day of the card month
const cardExpiry = new Date(parsedYear, parsedMonth + 1, 0);
// First day of the next month
const cardExpiry = new Date(parsedYear, parsedMonth + 1, 1);

return cardExpiry < now;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

original code is correctly getting the last day of the card month at exactly midnight (00:00:00), but now is currently after that. We actually want to see if the current moment is on or after the first moment of the next month after the expiry month (e.g. the 1st of the next month).

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 think my original intent here had been to see if the current moment was greater than the last moment of the expiry month)

return cardExpiry <= now;
}
}

Expand Down
Loading