Ghost/ghost/core/test/e2e-api/admin
Simon Backx 789e2c96c0
🐛 Fixed SingleUseTokens being cleared on boot (#15999)
fixes https://github.com/TryGhost/Team/issues/1996

**Issue**
Our Magic links are valid for 24 hours. After first usage, the token
lives for a further 10 minutes, so that in the case of email servers or
clients that "visit" links, the token can still be used.

The implementation of the 10 minute window uses setTimeout, meaning if
the process is interrupted, the 10 minute window is ignored completely,
and the token will continue to live for the remainder of it's 24 hour
validity period. To prevent that, the tokens are cleared on boot at the
moment.

**Solution**

To remove the boot clearing logic, we need to make sure the tokens are
only valid for 10 minutes after first use even during restarts.

This commit adds 3 new fields to the SingleUseToken model:
- updated_at: for storing the last time the token was changed/used). Not
really used atm.
- first_used_at: for storing the first time the token was used
- used_count: for storing the number of times the token has been used

Using these fields:
- A token can only be used 3 times
- A token is only valid for 10 minutes after first use, even if the
server restarts in between
- A token is only valid for 24 hours after creation (not changed)

We now also delete expired tokens in a separate job instead of on boot /
in a timeout.
2023-01-04 09:49:39 +01:00
..
__snapshots__ 🐛 Fixed tiers order by monthly_price (#16013) 2023-01-03 12:59:18 +04:00
actions.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
activity-feed.test.js Added events to Post Analytics page (#15886) 2022-11-28 17:43:35 +04:00
config.test.js 💡 Upgraded Tenor API to v2 (#15087) 2022-08-05 12:13:27 +01:00
custom-theme-settings.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
db.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
email-previews.test.js Added email service package (#15849) 2022-11-21 10:29:53 +01:00
emails.test.js Added email debug API (#15915) 2022-12-02 09:44:32 +01:00
explore.test.js Updated content-length header matchers 2022-10-05 17:34:17 +08:00
files.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
images.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
integrations.test.js Updated tests to incl. host limit cases for core integrations 2022-08-12 14:18:44 +01:00
invites.test.js Removed bluebird catch predicates from API endpoints 2022-08-24 11:27:09 +01:00
key-authentication.test.js Updated tests to incl. host limit cases for core integrations 2022-08-12 14:18:44 +01:00
labels.test.js Removed bluebird catch predicates from API endpoints 2022-08-24 11:27:09 +01:00
links.test.js Extracted sleep method to e2e framework module 2022-12-05 17:26:29 +07:00
media.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
members-exporter.test.js Added E2E tests for batch sending (#15910) 2022-12-01 13:43:49 +01:00
members-importer.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
members-newsletters.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
members-stripe-connect.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
members.test.js 🐛 Fixed importing existing member resetting newsletters (#16017) 2022-12-15 17:45:11 +01:00
newsletters.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
notifications.test.js Refactored notifications e2e tests to use test framework 2022-09-09 19:51:50 +08:00
oembed.test.js 🐛 Fixed embedded cards for non-utf8 content (#15578) 2022-10-13 12:19:47 +01:00
offers.test.js Handled stripe setup for free trial offers 2022-08-11 11:04:39 +05:30
pages.test.js Added rendering of posts.lexical to posts.html when saving (#15416) 2022-09-15 16:49:14 +01:00
posts-legacy.test.js Added email service package (#15849) 2022-11-21 10:29:53 +01:00
posts.test.js Hardened tiers-related snapshot tests 2022-10-27 15:54:28 +08:00
rate-limiting.test.js 🔒 Fixed rate limiting for user login (#15336) 2022-08-31 10:33:42 -04:00
redirects.test.js Improved performance of prepareContentFolder function 2022-08-01 08:58:13 +02:00
roles.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
session.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
settings-files.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
settings.test.js 🐛 Fixed SingleUseTokens being cleared on boot (#15999) 2023-01-04 09:49:39 +01:00
site.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
slugs.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
snippets.test.js Removed bluebird catch predicates from API endpoints 2022-08-24 11:27:09 +01:00
stats.test.js Added new referrer source stats API (#15449) 2022-09-22 16:34:26 +05:30
tags.test.js Removed bluebird catch predicates from API endpoints 2022-08-24 11:27:09 +01:00
themes.test.js Improved performance of prepareContentFolder function 2022-08-01 08:58:13 +02:00
tiers.test.js Fixed invalid query strings in tests 2022-11-30 13:31:06 +07:00
users.test.js Converted Ghost repo into a monorepo 2022-07-20 16:41:05 +02:00
utils.js Reduced default post relations (#15798) 2022-11-15 10:17:26 +01:00
webhooks.test.js Removed bluebird catch predicates from API endpoints 2022-08-24 11:27:09 +01:00