mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
A password account confirms its email before it signs in or uses the app. - Create account ends on Check your inbox, which names the address, sends the link again and says where to open it. The screen is the same whatever the address. - A password sign-in works once the address is confirmed, or in the browser that opened the account's own confirm link. Until then the right password is refused as a wrong one is, and the form offers Send the link again. - A signed-in account whose address is not confirmed sees Confirm your email instead of the app. The Worker answers its sessions and API tokens 403 EMAIL_UNCONFIRMED everywhere but me, logout, the signed-in resend, the link's finish route, and the billing portal for an account that pays. - POST /api/auth/verify-email/resend sends the link again while signed out, with limits and the captcha before any look-up. One budget of three confirm links an hour covers every way of asking for one. - Sign-up answers first, then makes the account, its profile and its first link in one batch, tried twice. Signing up again for an address waiting for its link mails a fresh link. - A sign-in code, a reset link and Google sign-in confirm the address. A passkey or two-factor does not. - /api/v1 capabilities, reminders and sheet syncs leave out an account waiting for its link. - The welcome and confirm mails say the link starts the account and where to sign in after opening it. No mail on the sign-up path has an em dash before the shared footer. No migration.
17 lines
807 B
TypeScript
17 lines
807 B
TypeScript
/**
|
|
* The API token a capability names. The /api/v1 routes read it when a capability is used
|
|
* (routes/v1.ts), so a test that signs one itself writes its token too: a row in api_tokens for
|
|
* `tokenId`, owned by `userId`, and revoked when `revoked` says so.
|
|
*/
|
|
import { env } from 'cloudflare:test';
|
|
|
|
export async function apiTokenRow(tokenId: string, userId: number, revoked = false): Promise<void> {
|
|
await env.DB.prepare(
|
|
`INSERT INTO api_tokens (id, user_id, name, token_hash, hint, scopes, revoked_at)
|
|
VALUES (?, ?, 'Capability test', ?, 'testhint', '["read","import"]', ?)
|
|
ON CONFLICT(id) DO UPDATE SET user_id = excluded.user_id, revoked_at = excluded.revoked_at`
|
|
)
|
|
.bind(tokenId, userId, `capability-test-${tokenId}`, revoked ? new Date().toISOString() : null)
|
|
.run();
|
|
}
|