Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
docs: describe setting and resetting a password
spacesdrive196041aa8659
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 512811e..b8474d1 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -19,6 +19,10 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).- Issue templates, a pull request template and `docs/workflows/ISSUES.md` describe the lifecycle, labels and `gh` commands- `ROADMAP.md` now starts with the project goals and links in-progress items to their issues+**Passwords for every account**+- Settings has a Password section to set or change the password; for an account that joined with Google it adds a password to the same account+- Forgot password on the sign-in page: enter the email, then the 6-digit code from the email and a new password; the reset email goes through the same capped email path as sign-up codes+**Email verification codes**- New email accounts are confirmed with a 6-digit code: after sign-up the page asks for the code, with a button to send a new one (once a minute), and signing in with an unconfirmed address opens the same step- Supabase Auth hands its emails to the backend through the Send Email hook (`POST /api/auth/email-hook`), which checks Supabase's signature and sends them for free through Resenddiff --git a/docs/architecture/backend/SERVICES.md b/docs/architecture/backend/SERVICES.mdindex 9959059..1029cbb 100644--- a/docs/architecture/backend/SERVICES.md+++ b/docs/architecture/backend/SERVICES.md@@ -73,7 +73,7 @@ Every user-scoped method takes the verified `userId` as its first argument. Meth`composeAuthEmails(hook, supabaseUrl)` in `email/authEmails.ts` turns one hook call into the emails to send, each with a plain text and an HTML body:-- `signup`, `recovery`, `magiclink`, `email`, `invite`: the 6-digit code and a link to Supabase Auth's `/auth/v1/verify` endpoint, which does the same.+- `signup`, `recovery`, `magiclink`, `email`, `invite`: the 6-digit code and a link to Supabase Auth's `/auth/v1/verify` endpoint, which does the same. The recovery email asks for the code on the sign-in page with the new password; its link signs the person in on Settings, where the Password section sets one.- `reauthentication`: the code only.- `email_change`: with Secure Email Change, one code to each address. Supabase names the hashes the other way round: the current address gets `token` with `token_hash_new`, the new one `token_new` with `token_hash`. Without it, one email to the new address.- `*_notification`: a notice of a change already made, with no code (`notice: true`).diff --git a/docs/architecture/data-flows/AUTHENTICATION.md b/docs/architecture/data-flows/AUTHENTICATION.mdindex 28512c2..a215db2 100644--- a/docs/architecture/data-flows/AUTHENTICATION.md+++ b/docs/architecture/data-flows/AUTHENTICATION.md@@ -70,6 +70,37 @@ Other cases on the login page:If the sign-up email cannot be sent, Supabase does not create the user, so the person can try again later or use Google. Password reset, magic link, invite, email change and security notice emails go through the same hook. Notices that hit a cap are skipped instead of failing the change they report. See `docs/architecture/backend/ROUTES.md` (Send Email hook) and `SERVICES.md` (Auth emails).+## Setting a Password from Settings++A signed-in member sets or changes their password in **Settings, Password** (`features/settings/PasswordSection.tsx`). No email is sent.++```+PasswordSection -> newPasswordProblem(password, confirmation) lib/passwords.ts: at least 6 characters, both fields match+ -> AuthContext.updatePassword(password) -> supabase.auth.updateUser({ password })+ -> "Password saved. You can now sign in with your email and this password."+```++Supabase keeps one user per email address, so for an account that only used Google this adds a password to the same user: email and password sign-in then opens the same data. `lib/authErrors.ts` (`passwordErrorMessage`) explains `same_password` and `reauthentication_needed`; a `weak_password` message lists what is missing and is shown as it is. Supabase's **Secure password change** (reauthentication) is off on this project; if it is turned on, an old session gets the sign-in-again message.++## Resetting a Forgotten Password++```+Login.tsx: Forgot password? (sign-in form) -> mode 'forgot' (LoginEmailForm)+ -> AuthContext.sendPasswordReset(email) -> supabase.auth.resetPasswordForEmail(email, { redirectTo: <origin>/settings })+ -> Supabase calls the Send Email hook with email_action_type 'recovery'+ -> the Worker emails the 6-digit code and a link, counted against the daily cap like every auth email+ -> "If an account uses <email>, a code is on its way." (Supabase answers the same for unknown addresses)+ │+ ▼+mode 'reset' (LoginCodeForm with a PasswordInput for the new password)+ -> AuthContext.verifyPasswordResetCode(email, code) -> supabase.auth.verifyOtp({ email, token, type: 'recovery' })+ the code signs the user in+ -> AuthContext.updatePassword(password)+ -> "Password saved" and the Overview; if the password is refused, the user is already signed in and is sent to Settings+```++The email's link does the same as the code: Supabase verifies it, signs the user in and opens Settings, where the Password section sets the new password. Send a new code, the 60 second wait and the daily-limit warning with the Google button work as on the sign-up code step. A Google-only account can use this flow to get a password.+## Sign in with GoogleOptional; enabled when `VITE_GOOGLE_CLIENT_ID` is set and the Google provider is on in Supabase.diff --git a/docs/architecture/frontend/CONTEXTS.md b/docs/architecture/frontend/CONTEXTS.mdindex 0f2c139..bc61df9 100644--- a/docs/architecture/frontend/CONTEXTS.md+++ b/docs/architecture/frontend/CONTEXTS.md@@ -7,7 +7,10 @@ Wraps Supabase Auth state and exposes it to the entire app.### What it provides```ts-const { session, user, signIn, signUp, verifySignUpCode, resendSignUpCode, signInWithGoogle, signOut } = useAuth();+const {+ session, user, signIn, signUp, verifySignUpCode, resendSignUpCode, sendPasswordReset, verifyPasswordResetCode, updatePassword,+ signInWithGoogle, signOut,+} = useAuth();```The value is typed as `AuthContextValue`, exported from `AuthContext.tsx`.@@ -20,6 +23,9 @@ The value is typed as `AuthContextValue`, exported from `AuthContext.tsx`.| `signUp(email, password)` | async function | Calls `supabase.auth.signUp()`. With **Confirm email** on it resolves with a user and no session, and the login page asks for the emailed code || `verifySignUpCode(email, code)` | async function | Calls `supabase.auth.verifyOtp({ email, token: code, type: 'signup' })`; a correct code confirms the address and signs the user in || `resendSignUpCode(email)` | async function | Calls `supabase.auth.resend({ type: 'signup', email })` to email a new code |+| `sendPasswordReset(email)` | async function | Calls `supabase.auth.resetPasswordForEmail(email, { redirectTo: <origin>/settings })`; the email carries a recovery code and a link |+| `verifyPasswordResetCode(email, code)` | async function | Calls `supabase.auth.verifyOtp({ email, token: code, type: 'recovery' })`; a correct code signs the user in |+| `updatePassword(password)` | async function | Calls `supabase.auth.updateUser({ password })`; sets or changes the password, including for an account that only used Google || `signInWithGoogle(idToken, nonce)` | async function | Calls `supabase.auth.signInWithIdToken({ provider: 'google', token, nonce })` with the ID token from Google's button and the raw nonce || `signOut()` | async function | Calls `supabase.auth.signOut()` |@@ -42,7 +48,8 @@ useEffect(() => {### Where to use it- `ProtectedRoute` - reads `session` to decide whether to redirect to `/login`-- `Login.tsx` - calls `signIn()`, `signUp()`, `verifySignUpCode()`, `resendSignUpCode()` and `signInWithGoogle()`+- `Login.tsx` - calls `signIn()`, `signUp()`, `verifySignUpCode()`, `resendSignUpCode()`, `sendPasswordReset()`, `verifyPasswordResetCode()`, `updatePassword()` and `signInWithGoogle()`+- `features/settings/PasswordSection.tsx` - calls `updatePassword()` and reads `user.email` for password managers- `Header.tsx` - calls `signOut()`, shows `user.email`- Do **not** use in page/feature components - they should never need auth state directlydiff --git a/docs/architecture/frontend/FEATURES.md b/docs/architecture/frontend/FEATURES.mdindex 5936317..0af0816 100644--- a/docs/architecture/frontend/FEATURES.md+++ b/docs/architecture/frontend/FEATURES.md@@ -92,7 +92,7 @@ frontend/src/│ │ └── publishHelpers.ts, scheduleHelpers.ts, queueHelpers.ts <- Pure helpers with *.test.ts│ ├── settings/│ │ ├── Settings.tsx <- Page: loads server settings, then renders each section; keeps the #hash scroll-│ │ ├── SettingsSection.tsx, AppearanceSection.tsx, ServerKeysSection.tsx, SchedulingSection.tsx+│ │ ├── SettingsSection.tsx, AppearanceSection.tsx, PasswordSection.tsx, ServerKeysSection.tsx, SchedulingSection.tsx│ │ ├── PlatformRequirementsSection.tsx, UsefulLinksSection.tsx│ │ ├── SchedulingSetupGuide.tsx <- Optional GitHub backup scheduler steps for administrators│ │ ├── SchedulingSetupSteps.tsx, SetupStep.tsx, GithubRepoForm.tsx, CopyChip.tsx, GuideLinkButton.tsx, RepoLinkButton.tsxdiff --git a/docs/architecture/frontend/REACT_ARCHITECTURE.md b/docs/architecture/frontend/REACT_ARCHITECTURE.mdindex 46ff3ee..28b3234 100644--- a/docs/architecture/frontend/REACT_ARCHITECTURE.md+++ b/docs/architecture/frontend/REACT_ARCHITECTURE.md@@ -113,7 +113,10 @@ frontend/src/pages/Login.tsx Auth page (not lazy-loaded, always small); owns mode (sign in, sign up, code), fields, the password toggle and the resend waitLoginForm.tsx Email and password form- LoginCodeForm.tsx The 6-digit email code step after sign-up, with Send a new code+ LoginCodeForm.tsx The 6-digit email code step (sign-up confirmation, and password reset with a new-password field), with Send a new code+ LoginEmailForm.tsx The email-only Forgot password step+ PasswordInput.tsx Password field with its show or hide button, used by the sign-in, sign-up and reset forms+ useCountdown.ts Seconds until another email code may be sentLoginBrandPanel.tsx Decorative product preview beside the formloginCopy.ts Sign-in and sign-up text, privacy linkfeatures/diff --git a/docs/workflows/TESTING.md b/docs/workflows/TESTING.mdindex 9a2226d..3e9b77e 100644--- a/docs/workflows/TESTING.md+++ b/docs/workflows/TESTING.md@@ -35,6 +35,7 @@ Tests never sit next to source files. Each workspace has a `tests/` folder that| `backend/routes/authHookRoutes.ts` | `backend/tests/routes/authHookRoutes.test.ts` || `backend/services/authEmailService.ts` | `backend/tests/services/authEmailService.test.ts` || `frontend/src/lib/authErrors.ts` | `frontend/tests/lib/authErrors.test.ts` |+| `frontend/src/lib/passwords.ts` | `frontend/tests/lib/passwords.test.ts` || `frontend/src/features/analytics/overview/overviewStats.ts` | `frontend/tests/features/analytics/overview/overviewStats.test.ts` || `frontend/src/docs/nav.ts` | `frontend/tests/docs/nav.test.ts` |@@ -131,6 +132,12 @@ Open the app in a browser. For each changed area, test:- [ ] `npx wrangler tail` shows `auth email sent` for each code, and no code in any log line- [ ] To check the daily cap without spending the quota, run the Worker locally with `EMAIL_DAILY_LIMIT=1` and no Redis, and send signed requests (see `tests/fixtures/authHook.ts` for the signing) -> the second one answers 429 with the Google message+**Passwords (if the Password section, the reset steps or the recovery email changed):**+- [ ] Settings, Password: mismatched fields -> "The two passwords do not match"; a valid password -> saved, and signing out and in with it works+- [ ] An account created with Google sets a password in Settings, then signs in with email and that password and sees the same accounts+- [ ] Sign-in page, Forgot password? -> the email step -> a recovery code arrives -> a wrong code shows "The code is wrong or has expired" -> the right code and a new password land on Overview+- [ ] The link in the recovery email opens Settings signed in+**Request pipeline (if middleware, CORS or error handling changed):**- [ ] Every response, including errors, has an `X-Request-Id` header and the security headers (`Content-Security-Policy`, `X-Frame-Options: DENY`, `Referrer-Policy: no-referrer`, `X-Content-Type-Options: nosniff`)- [ ] `curl -i -H "Origin: <FRONTEND_URL>" .../api/health` returns `Access-Control-Allow-Origin` with that origindiff --git a/frontend/src/docs/pages/use/GettingStarted.tsx b/frontend/src/docs/pages/use/GettingStarted.tsxindex 5efebad..8434c50 100644--- a/frontend/src/docs/pages/use/GettingStarted.tsx+++ b/frontend/src/docs/pages/use/GettingStarted.tsx@@ -12,7 +12,7 @@ export default function GettingStarted() {<Steps><Step title="Create your account">- <P>Open your instance's link and choose <strong>Continue with Google</strong>, if your instance offers it. Otherwise choose <strong>Create an account</strong> and use your email and a password of at least 6 characters, then sign in. If you sign in with Google using the same email as an existing account, both open the same account.</P>+ <P>Open your instance's link and choose <strong>Continue with Google</strong>, if your instance offers it. Otherwise choose <strong>Create an account</strong> and use your email and a password of at least 6 characters, then enter the 6-digit code we email you. If you sign in with Google using the same email as an existing account, both open the same account. If you joined with Google and also want a password, set one in <strong>Settings</strong>, <strong>Password</strong>. Forgot it? Choose <strong>Forgot password?</strong> on the sign-in page and enter the 6-digit code we email you with a new password.</P></Step><Step title="Connect an account"><P>Open <strong>Accounts</strong> in the sidebar and choose <strong>Add account</strong>. Pick YouTube, Instagram or Reddit. Each one is explained in <A to="/docs/use/connect-accounts">Connect your accounts</A>.</P>