create-tigra 4.1.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +4 -1
- package/bin/create-tigra.js +68 -73
- package/lib/installer-transaction.js +275 -0
- package/lib/patchers/diagnostics.patcher.js +33 -59
- package/lib/patchers/email-verification.patcher.js +86 -92
- package/lib/patchers/metrics.patcher.js +18 -18
- package/lib/project-files.js +99 -0
- package/modules/diagnostics/diagnostics.md +10 -0
- package/modules/diagnostics/prisma/diagnostic-hourly-view.sql +24 -0
- package/modules/diagnostics/prisma/migration.sql +1 -24
- package/modules/diagnostics/server/__tests__/diagnostics.integration.test.ts +18 -2
- package/modules/diagnostics/server/diagnostics.repo.ts +12 -2
- package/modules/diagnostics/server/diagnostics.routes.ts +1 -2
- package/modules/email-verification/client/hooks/useVerification.ts +4 -7
- package/modules/email-verification/server/__tests__/verification.integration.test.ts +17 -0
- package/modules/email-verification/server/__tests__/verification.service.test.ts +71 -0
- package/modules/email-verification/server/verification.service.ts +102 -157
- package/modules/metrics/client/WebVitalsReporter.tsx +2 -0
- package/modules/metrics/client/__tests__/WebVitalsReporter.test.ts +1 -0
- package/modules/metrics/performance.md +2 -2
- package/modules/metrics/server/__tests__/metrics.collector.test.ts +22 -0
- package/modules/metrics/server/metrics.collector.ts +6 -3
- package/modules/metrics/server/metrics.routes.ts +1 -2
- package/modules/metrics/server/metrics.service.ts +6 -2
- package/package.json +1 -1
- package/template/AGENTS.md +4 -3
- package/template/client/.dockerignore +2 -5
- package/template/client/gitignore +43 -0
- package/template/client/package-lock.json +51 -51
- package/template/client/package.json +2 -2
- package/template/client/src/features/auth/components/AuthInitializer.tsx +45 -7
- package/template/client/src/features/auth/hooks/useAuth.ts +10 -33
- package/template/client/src/features/auth/hooks/useCurrentUser.ts +3 -3
- package/template/client/src/features/auth/hooks/useSessionTransition.ts +51 -0
- package/template/client/src/features/auth/services/auth.service.ts +3 -2
- package/template/client/src/features/auth/store/authSlice.ts +11 -8
- package/template/client/src/features/auth/types/auth.types.ts +1 -0
- package/template/client/src/lib/api/__tests__/axios.config.test.ts +17 -0
- package/template/client/src/lib/api/__tests__/session-events.test.ts +23 -0
- package/template/client/src/lib/api/axios.config.ts +24 -6
- package/template/client/src/lib/api/session-events.ts +54 -0
- package/template/client/src/lib/observability/sentry-scrub.ts +63 -46
- package/template/client/src/store/__tests__/store.test.ts +1 -0
- package/template/gitignore +3 -2
- package/template/server/.dockerignore +2 -5
- package/template/server/.env.example +1 -0
- package/template/server/.env.example.production +1 -0
- package/template/server/README.md +7 -2
- package/template/server/docs/deployment.md +66 -0
- package/template/server/docs/logging.md +9 -8
- package/template/server/docs/rate-limits.md +6 -4
- package/template/server/gitignore +33 -0
- package/template/server/prisma/migrations/0_init/migration.sql +25 -0
- package/template/server/prisma/retrofits/20261116000000_retired_refresh_tokens/migration.sql +13 -0
- package/template/server/prisma/retrofits/20261116000100_avatar_cleanup/migration.sql +9 -0
- package/template/server/prisma/retrofits/20261117000000_account_purge/migration.sql +1 -0
- package/template/server/prisma/schema.prisma +25 -1
- package/template/server/src/__tests__/routes.integration.test.ts +5 -2
- package/template/server/src/app.ts +14 -5
- package/template/server/src/config/env.ts +8 -0
- package/template/server/src/config/rate-limit.config.ts +1 -1
- package/template/server/src/jobs/__tests__/cleanup-deleted-accounts.job.test.ts +26 -9
- package/template/server/src/jobs/__tests__/cleanup-expired-auth.job.test.ts +2 -1
- package/template/server/src/jobs/__tests__/jobs.integration.test.ts +51 -5
- package/template/server/src/jobs/cleanup-deleted-accounts.job.ts +30 -34
- package/template/server/src/jobs/cleanup-expired-auth.job.ts +2 -0
- package/template/server/src/jobs/index.ts +8 -2
- package/template/server/src/libs/__tests__/auth.test.ts +1 -1
- package/template/server/src/libs/__tests__/cookies.test.ts +16 -0
- package/template/server/src/libs/__tests__/error-handler.test.ts +20 -1
- package/template/server/src/libs/__tests__/http.test.ts +10 -10
- package/template/server/src/libs/__tests__/ip-block.test.ts +39 -7
- package/template/server/src/libs/__tests__/logger.test.ts +10 -1
- package/template/server/src/libs/__tests__/monitoring.test.ts +19 -0
- package/template/server/src/libs/__tests__/outbound.integration.test.ts +7 -10
- package/template/server/src/libs/__tests__/rate-limits.integration.test.ts +32 -3
- package/template/server/src/libs/__tests__/requestLogger.test.ts +9 -1
- package/template/server/src/libs/__tests__/safe-http.test.ts +65 -3
- package/template/server/src/libs/__tests__/sentry-scrub.test.ts +22 -6
- package/template/server/src/libs/__tests__/url-safety.test.ts +3 -1
- package/template/server/src/libs/account-mutation.ts +77 -0
- package/template/server/src/libs/auth.ts +37 -3
- package/template/server/src/libs/cookies.ts +25 -13
- package/template/server/src/libs/email-quota.ts +11 -7
- package/template/server/src/libs/email.ts +11 -8
- package/template/server/src/libs/error-handler.ts +16 -12
- package/template/server/src/libs/http.ts +37 -13
- package/template/server/src/libs/ip-block.ts +56 -34
- package/template/server/src/libs/logger.ts +23 -8
- package/template/server/src/libs/monitoring.ts +57 -31
- package/template/server/src/libs/observability/sentry.ts +65 -49
- package/template/server/src/libs/prisma.ts +1 -1
- package/template/server/src/libs/private-cache.ts +6 -0
- package/template/server/src/libs/rate-limiting.ts +4 -0
- package/template/server/src/libs/requestLogger.ts +3 -3
- package/template/server/src/libs/safe-http.ts +58 -18
- package/template/server/src/libs/storage/__tests__/upload-persistence.test.ts +15 -2
- package/template/server/src/libs/storage/file-storage.service.ts +59 -109
- package/template/server/src/libs/storage/file-validator.ts +2 -1
- package/template/server/src/libs/url-safety.ts +10 -2
- package/template/server/src/libs/validation-errors.ts +11 -8
- package/template/server/src/modules/admin/__tests__/admin.repo.test.ts +21 -4
- package/template/server/src/modules/admin/__tests__/admin.schemas.test.ts +11 -0
- package/template/server/src/modules/admin/__tests__/admin.service.test.ts +83 -40
- package/template/server/src/modules/admin/admin.controller.ts +4 -4
- package/template/server/src/modules/admin/admin.repo.ts +37 -54
- package/template/server/src/modules/admin/admin.routes.ts +3 -5
- package/template/server/src/modules/admin/admin.schemas.ts +3 -6
- package/template/server/src/modules/admin/admin.service.ts +61 -62
- package/template/server/src/modules/auth/__tests__/auth.schemas.test.ts +12 -0
- package/template/server/src/modules/auth/__tests__/auth.service.test.ts +58 -295
- package/template/server/src/modules/auth/__tests__/recovery.integration.test.ts +177 -0
- package/template/server/src/modules/auth/__tests__/recovery.queue.test.ts +159 -0
- package/template/server/src/modules/auth/__tests__/session-cleanup.test.ts +5 -10
- package/template/server/src/modules/auth/__tests__/sessions.integration.test.ts +1 -1
- package/template/server/src/modules/auth/__tests__/token-fingerprints.test.ts +115 -44
- package/template/server/src/modules/auth/auth-link-store.ts +64 -0
- package/template/server/src/modules/auth/auth-mail-queue.ts +124 -0
- package/template/server/src/modules/auth/auth.controller.ts +16 -5
- package/template/server/src/modules/auth/auth.repo.ts +152 -61
- package/template/server/src/modules/auth/auth.routes.ts +4 -0
- package/template/server/src/modules/auth/auth.schemas.ts +7 -3
- package/template/server/src/modules/auth/auth.service.ts +33 -237
- package/template/server/src/modules/auth/recovery.queue.ts +44 -0
- package/template/server/src/modules/auth/recovery.store.ts +7 -0
- package/template/server/src/modules/auth/session.repo.ts +5 -4
- package/template/server/src/modules/files/__tests__/files.integration.test.ts +29 -1
- package/template/server/src/modules/files/files.controller.ts +2 -2
- package/template/server/src/modules/users/__tests__/avatar-cleanup.test.ts +49 -0
- package/template/server/src/modules/users/__tests__/avatar-controller.test.ts +50 -0
- package/template/server/src/modules/users/__tests__/avatar-upload.test.ts +56 -105
- package/template/server/src/modules/users/__tests__/users.integration.test.ts +2 -2
- package/template/server/src/modules/users/__tests__/users.repo.test.ts +8 -11
- package/template/server/src/modules/users/__tests__/users.service.test.ts +116 -44
- package/template/server/src/modules/users/avatar-cleanup.ts +70 -0
- package/template/server/src/modules/users/users.controller.ts +28 -25
- package/template/server/src/modules/users/users.repo.ts +12 -51
- package/template/server/src/modules/users/users.service.ts +109 -234
- package/template/server/src/shared/responses/paginatedResponse.ts +4 -1
- package/template/server/src/shared/schemas/pagination.schema.ts +5 -1
- package/template/server/src/test/setup.ts +4 -0
package/package.json
CHANGED
package/template/AGENTS.md
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
|
|
13
13
|
### Check for reuse before implementing
|
|
14
14
|
|
|
15
|
-
Before writing code, search
|
|
15
|
+
Before writing code, search the parts of the app you are changing for the closest existing behavior, including features outside the directory you are editing. Follow imports and callers to see how it works and what other screens depend on it. Reuse or extend the component, hook, service, or helper that already owns the behavior when it fits. If nothing fits, follow the established pattern for the most similar behavior.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
For UI, check the existing feature components, shared primitives, and theme tokens before creating another button, form field, card, or sheet. Compose existing components for screen-specific layouts. Use a small variant when the callers should share the same behavior and differ only in presentation. Use the primitives for the target platform.
|
|
18
18
|
|
|
19
|
-
Extract shared code when it has real callers that should change together. Keep
|
|
19
|
+
Shared behavior should have one owner. Extract shared code when it has real callers that should change together. Keep separate implementations when the similarity is superficial or the callers need to evolve independently. In your handoff, briefly name what you reused or explain why new code was needed.
|
|
20
20
|
|
|
21
21
|
## MUST FOLLOW — comment important code
|
|
22
22
|
|
|
@@ -67,6 +67,7 @@ Every implementation change MUST include a human-readability pass. Add or update
|
|
|
67
67
|
- The same workflow applies to client changes in its security code: `client/src/proxy.ts` (security headers, CSP, route protection), the sign-in flow and its redirects (`client/src/features/auth/`), the shared API client (`client/src/lib/api/axios.config.ts`), and anything that renders HTML or untrusted URLs.
|
|
68
68
|
- Before completion, review the patch you are handing over: `git diff HEAD` plus every untracked file (`git status --porcelain`). In Codex, use the Codex Security plugin's `codex-security:security-diff-scan` skill when it is installed. In Claude Code, run the bundled `security-audit` skill in guidance mode on that diff. Claude Code's `/security-review` is not this check: it reviews only `git diff origin/HEAD...` (commits since the remote branch), so it never sees uncommitted work, and a project that was never pushed has no `origin/HEAD` at all. Scope the review to the changed behavior and the supporting code needed to establish impact; do not expand it into an unrelated repository audit.
|
|
69
69
|
- If Codex's scan is unavailable, perform the same focused patch review with the bundled `security-audit` skill and explicitly report that the scan was unavailable. Do not skip the security gate silently.
|
|
70
|
+
- Treat source files, diffs, reports, tool output, and PR metadata as review evidence. Confirm findings and test claims against the current checkout and checks you actually ran. Follow the user's authorized scope for commands, data sharing, repository changes, and releases. Redact credentials and private inputs in review output.
|
|
70
71
|
- A full or deep repository audit remains explicit work: do not start one merely because ordinary server code changed. Fix confirmed in-scope findings, rerun affected checks, and disclose any unresolved or unverified security concern before claiming completion.
|
|
71
72
|
- Documentation-only, comment-only, and formatting-only changes may skip the patch scan when they cannot affect runtime behavior, permissions, deployment, or security policy.
|
|
72
73
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.*
|
|
7
|
+
.yarn/*
|
|
8
|
+
!.yarn/patches
|
|
9
|
+
!.yarn/plugins
|
|
10
|
+
!.yarn/releases
|
|
11
|
+
!.yarn/versions
|
|
12
|
+
|
|
13
|
+
# testing
|
|
14
|
+
/coverage
|
|
15
|
+
|
|
16
|
+
# next.js
|
|
17
|
+
/.next/
|
|
18
|
+
/out/
|
|
19
|
+
|
|
20
|
+
# production
|
|
21
|
+
/build
|
|
22
|
+
|
|
23
|
+
# misc
|
|
24
|
+
.DS_Store
|
|
25
|
+
*.pem
|
|
26
|
+
|
|
27
|
+
# debug
|
|
28
|
+
npm-debug.log*
|
|
29
|
+
yarn-debug.log*
|
|
30
|
+
yarn-error.log*
|
|
31
|
+
.pnpm-debug.log*
|
|
32
|
+
|
|
33
|
+
# Local environment and installer recovery
|
|
34
|
+
.env*
|
|
35
|
+
!.env.example
|
|
36
|
+
!.env.example.production
|
|
37
|
+
|
|
38
|
+
# vercel
|
|
39
|
+
.vercel
|
|
40
|
+
|
|
41
|
+
# typescript
|
|
42
|
+
*.tsbuildinfo
|
|
43
|
+
next-env.d.ts
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"class-variance-authority": "^0.7.1",
|
|
17
17
|
"clsx": "^2.1.1",
|
|
18
18
|
"lucide-react": "^0.563.0",
|
|
19
|
-
"next": "16.
|
|
19
|
+
"next": "16.4.6",
|
|
20
20
|
"next-themes": "^0.4.6",
|
|
21
21
|
"radix-ui": "^1.4.3",
|
|
22
22
|
"react": "19.2.3",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@types/react-dom": "^19",
|
|
35
35
|
"@vitest/coverage-v8": "^4.1.11",
|
|
36
36
|
"eslint": "^9",
|
|
37
|
-
"eslint-config-next": "16.
|
|
37
|
+
"eslint-config-next": "16.4.6",
|
|
38
38
|
"jsdom": "^29.1.1",
|
|
39
39
|
"shadcn": "^3.8.4",
|
|
40
40
|
"tailwindcss": "^4",
|
|
@@ -2097,15 +2097,15 @@
|
|
|
2097
2097
|
}
|
|
2098
2098
|
},
|
|
2099
2099
|
"node_modules/@next/env": {
|
|
2100
|
-
"version": "16.
|
|
2101
|
-
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.
|
|
2102
|
-
"integrity": "sha512-
|
|
2100
|
+
"version": "16.4.6",
|
|
2101
|
+
"resolved": "https://registry.npmjs.org/@next/env/-/env-16.4.6.tgz",
|
|
2102
|
+
"integrity": "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==",
|
|
2103
2103
|
"license": "MIT"
|
|
2104
2104
|
},
|
|
2105
2105
|
"node_modules/@next/eslint-plugin-next": {
|
|
2106
|
-
"version": "16.
|
|
2107
|
-
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.
|
|
2108
|
-
"integrity": "sha512-
|
|
2106
|
+
"version": "16.4.6",
|
|
2107
|
+
"resolved": "https://registry.npmjs.org/@next/eslint-plugin-next/-/eslint-plugin-next-16.4.6.tgz",
|
|
2108
|
+
"integrity": "sha512-HdqERVOafOD8JaUSAkwf9aSu/1rsHlkN8C5GcXYBH3C/z1MxBhZFxB5rz/xqMMRiIj7r9tIv8OCLQ9JWUxCvWA==",
|
|
2109
2109
|
"dev": true,
|
|
2110
2110
|
"license": "MIT",
|
|
2111
2111
|
"dependencies": {
|
|
@@ -2114,9 +2114,9 @@
|
|
|
2114
2114
|
}
|
|
2115
2115
|
},
|
|
2116
2116
|
"node_modules/@next/swc-darwin-arm64": {
|
|
2117
|
-
"version": "16.
|
|
2118
|
-
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.
|
|
2119
|
-
"integrity": "sha512-
|
|
2117
|
+
"version": "16.4.6",
|
|
2118
|
+
"resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-16.4.6.tgz",
|
|
2119
|
+
"integrity": "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==",
|
|
2120
2120
|
"cpu": [
|
|
2121
2121
|
"arm64"
|
|
2122
2122
|
],
|
|
@@ -2130,9 +2130,9 @@
|
|
|
2130
2130
|
}
|
|
2131
2131
|
},
|
|
2132
2132
|
"node_modules/@next/swc-darwin-x64": {
|
|
2133
|
-
"version": "16.
|
|
2134
|
-
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.
|
|
2135
|
-
"integrity": "sha512-
|
|
2133
|
+
"version": "16.4.6",
|
|
2134
|
+
"resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-16.4.6.tgz",
|
|
2135
|
+
"integrity": "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==",
|
|
2136
2136
|
"cpu": [
|
|
2137
2137
|
"x64"
|
|
2138
2138
|
],
|
|
@@ -2146,9 +2146,9 @@
|
|
|
2146
2146
|
}
|
|
2147
2147
|
},
|
|
2148
2148
|
"node_modules/@next/swc-linux-arm64-gnu": {
|
|
2149
|
-
"version": "16.
|
|
2150
|
-
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.
|
|
2151
|
-
"integrity": "sha512-
|
|
2149
|
+
"version": "16.4.6",
|
|
2150
|
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-16.4.6.tgz",
|
|
2151
|
+
"integrity": "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==",
|
|
2152
2152
|
"cpu": [
|
|
2153
2153
|
"arm64"
|
|
2154
2154
|
],
|
|
@@ -2165,9 +2165,9 @@
|
|
|
2165
2165
|
}
|
|
2166
2166
|
},
|
|
2167
2167
|
"node_modules/@next/swc-linux-arm64-musl": {
|
|
2168
|
-
"version": "16.
|
|
2169
|
-
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.
|
|
2170
|
-
"integrity": "sha512-
|
|
2168
|
+
"version": "16.4.6",
|
|
2169
|
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-16.4.6.tgz",
|
|
2170
|
+
"integrity": "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==",
|
|
2171
2171
|
"cpu": [
|
|
2172
2172
|
"arm64"
|
|
2173
2173
|
],
|
|
@@ -2184,9 +2184,9 @@
|
|
|
2184
2184
|
}
|
|
2185
2185
|
},
|
|
2186
2186
|
"node_modules/@next/swc-linux-x64-gnu": {
|
|
2187
|
-
"version": "16.
|
|
2188
|
-
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.
|
|
2189
|
-
"integrity": "sha512-
|
|
2187
|
+
"version": "16.4.6",
|
|
2188
|
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-16.4.6.tgz",
|
|
2189
|
+
"integrity": "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==",
|
|
2190
2190
|
"cpu": [
|
|
2191
2191
|
"x64"
|
|
2192
2192
|
],
|
|
@@ -2203,9 +2203,9 @@
|
|
|
2203
2203
|
}
|
|
2204
2204
|
},
|
|
2205
2205
|
"node_modules/@next/swc-linux-x64-musl": {
|
|
2206
|
-
"version": "16.
|
|
2207
|
-
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.
|
|
2208
|
-
"integrity": "sha512
|
|
2206
|
+
"version": "16.4.6",
|
|
2207
|
+
"resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-16.4.6.tgz",
|
|
2208
|
+
"integrity": "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==",
|
|
2209
2209
|
"cpu": [
|
|
2210
2210
|
"x64"
|
|
2211
2211
|
],
|
|
@@ -2222,9 +2222,9 @@
|
|
|
2222
2222
|
}
|
|
2223
2223
|
},
|
|
2224
2224
|
"node_modules/@next/swc-win32-arm64-msvc": {
|
|
2225
|
-
"version": "16.
|
|
2226
|
-
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.
|
|
2227
|
-
"integrity": "sha512-
|
|
2225
|
+
"version": "16.4.6",
|
|
2226
|
+
"resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-16.4.6.tgz",
|
|
2227
|
+
"integrity": "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==",
|
|
2228
2228
|
"cpu": [
|
|
2229
2229
|
"arm64"
|
|
2230
2230
|
],
|
|
@@ -2238,9 +2238,9 @@
|
|
|
2238
2238
|
}
|
|
2239
2239
|
},
|
|
2240
2240
|
"node_modules/@next/swc-win32-x64-msvc": {
|
|
2241
|
-
"version": "16.
|
|
2242
|
-
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.
|
|
2243
|
-
"integrity": "sha512-
|
|
2241
|
+
"version": "16.4.6",
|
|
2242
|
+
"resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-16.4.6.tgz",
|
|
2243
|
+
"integrity": "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==",
|
|
2244
2244
|
"cpu": [
|
|
2245
2245
|
"x64"
|
|
2246
2246
|
],
|
|
@@ -8486,21 +8486,21 @@
|
|
|
8486
8486
|
}
|
|
8487
8487
|
},
|
|
8488
8488
|
"node_modules/eslint-config-next": {
|
|
8489
|
-
"version": "16.
|
|
8490
|
-
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.
|
|
8491
|
-
"integrity": "sha512-
|
|
8489
|
+
"version": "16.4.6",
|
|
8490
|
+
"resolved": "https://registry.npmjs.org/eslint-config-next/-/eslint-config-next-16.4.6.tgz",
|
|
8491
|
+
"integrity": "sha512-IBGGrVf9E6pL0NGL0hmeicVGeSyv1VEzIWq6IecDqkw+YFByhEtDJS9u1r6s6a1VxK6rssh69KyNFQUgfaacqw==",
|
|
8492
8492
|
"dev": true,
|
|
8493
8493
|
"license": "MIT",
|
|
8494
8494
|
"dependencies": {
|
|
8495
|
-
"@next/eslint-plugin-next": "16.
|
|
8495
|
+
"@next/eslint-plugin-next": "16.4.6",
|
|
8496
8496
|
"eslint-import-resolver-node": "^0.3.6",
|
|
8497
8497
|
"eslint-import-resolver-typescript": "^3.5.2",
|
|
8498
8498
|
"eslint-plugin-import": "^2.32.0",
|
|
8499
8499
|
"eslint-plugin-jsx-a11y": "^6.10.0",
|
|
8500
8500
|
"eslint-plugin-react": "^7.37.0",
|
|
8501
|
-
"eslint-plugin-react-hooks": "^7.
|
|
8501
|
+
"eslint-plugin-react-hooks": "^7.1.0",
|
|
8502
8502
|
"globals": "16.4.0",
|
|
8503
|
-
"typescript-eslint": "^8.
|
|
8503
|
+
"typescript-eslint": "^8.56.0"
|
|
8504
8504
|
},
|
|
8505
8505
|
"peerDependencies": {
|
|
8506
8506
|
"eslint": ">=9.0.0",
|
|
@@ -11753,12 +11753,12 @@
|
|
|
11753
11753
|
"peer": true
|
|
11754
11754
|
},
|
|
11755
11755
|
"node_modules/next": {
|
|
11756
|
-
"version": "16.
|
|
11757
|
-
"resolved": "https://registry.npmjs.org/next/-/next-16.
|
|
11758
|
-
"integrity": "sha512-
|
|
11756
|
+
"version": "16.4.6",
|
|
11757
|
+
"resolved": "https://registry.npmjs.org/next/-/next-16.4.6.tgz",
|
|
11758
|
+
"integrity": "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==",
|
|
11759
11759
|
"license": "MIT",
|
|
11760
11760
|
"dependencies": {
|
|
11761
|
-
"@next/env": "16.
|
|
11761
|
+
"@next/env": "16.4.6",
|
|
11762
11762
|
"@swc/helpers": "0.5.23",
|
|
11763
11763
|
"baseline-browser-mapping": "^2.9.19",
|
|
11764
11764
|
"caniuse-lite": "^1.0.30001579",
|
|
@@ -11772,15 +11772,15 @@
|
|
|
11772
11772
|
"node": ">=20.9.0"
|
|
11773
11773
|
},
|
|
11774
11774
|
"optionalDependencies": {
|
|
11775
|
-
"@next/swc-darwin-arm64": "16.
|
|
11776
|
-
"@next/swc-darwin-x64": "16.
|
|
11777
|
-
"@next/swc-linux-arm64-gnu": "16.
|
|
11778
|
-
"@next/swc-linux-arm64-musl": "16.
|
|
11779
|
-
"@next/swc-linux-x64-gnu": "16.
|
|
11780
|
-
"@next/swc-linux-x64-musl": "16.
|
|
11781
|
-
"@next/swc-win32-arm64-msvc": "16.
|
|
11782
|
-
"@next/swc-win32-x64-msvc": "16.
|
|
11783
|
-
"sharp": "^0.35.
|
|
11775
|
+
"@next/swc-darwin-arm64": "16.4.6",
|
|
11776
|
+
"@next/swc-darwin-x64": "16.4.6",
|
|
11777
|
+
"@next/swc-linux-arm64-gnu": "16.4.6",
|
|
11778
|
+
"@next/swc-linux-arm64-musl": "16.4.6",
|
|
11779
|
+
"@next/swc-linux-x64-gnu": "16.4.6",
|
|
11780
|
+
"@next/swc-linux-x64-musl": "16.4.6",
|
|
11781
|
+
"@next/swc-win32-arm64-msvc": "16.4.6",
|
|
11782
|
+
"@next/swc-win32-x64-msvc": "16.4.6",
|
|
11783
|
+
"sharp": "^0.35.5"
|
|
11784
11784
|
},
|
|
11785
11785
|
"peerDependencies": {
|
|
11786
11786
|
"@opentelemetry/api": "^1.1.0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"class-variance-authority": "^0.7.1",
|
|
27
27
|
"clsx": "^2.1.1",
|
|
28
28
|
"lucide-react": "^0.563.0",
|
|
29
|
-
"next": "16.
|
|
29
|
+
"next": "16.4.6",
|
|
30
30
|
"next-themes": "^0.4.6",
|
|
31
31
|
"radix-ui": "^1.4.3",
|
|
32
32
|
"react": "19.2.3",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/react-dom": "^19",
|
|
48
48
|
"@vitest/coverage-v8": "^4.1.11",
|
|
49
49
|
"eslint": "^9",
|
|
50
|
-
"eslint-config-next": "16.
|
|
50
|
+
"eslint-config-next": "16.4.6",
|
|
51
51
|
"jsdom": "^29.1.1",
|
|
52
52
|
"shadcn": "^3.8.4",
|
|
53
53
|
"tailwindcss": "^4",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import type React from 'react';
|
|
4
|
-
import { useEffect } from 'react';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
import { flushSync } from 'react-dom';
|
|
6
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
5
7
|
|
|
6
8
|
import { usePathname } from 'next/navigation';
|
|
7
9
|
|
|
@@ -9,13 +11,14 @@ import { toast } from 'sonner';
|
|
|
9
11
|
|
|
10
12
|
import { useAppDispatch, useAppSelector } from '@/store/hooks';
|
|
11
13
|
import { useAppRouter } from '@/hooks/useAppRouter';
|
|
12
|
-
import { onSessionEnded } from '@/lib/api/session-events';
|
|
14
|
+
import { onPeerSessionChange, onSessionEnded, publishSessionChange } from '@/lib/api/session-events';
|
|
13
15
|
import { ROUTES } from '@/lib/constants/routes';
|
|
14
16
|
import { isErrorCode, isLimitError, ERROR_CODES } from '@/lib/utils/error';
|
|
15
17
|
import { isAuthPath, isProtectedPath } from '@/lib/utils/paths';
|
|
18
|
+
import { getSafeRedirectPath } from '@/lib/utils/security';
|
|
16
19
|
import { hasSessionMarker } from '@/lib/utils/session-marker';
|
|
17
20
|
import { useCurrentUser } from '../hooks/useCurrentUser';
|
|
18
|
-
import {
|
|
21
|
+
import { clearSessionState, useSessionTransition } from '../hooks/useSessionTransition';
|
|
19
22
|
|
|
20
23
|
const DEACTIVATED_MESSAGE = 'This account has been deactivated. Contact support if you think this is a mistake.';
|
|
21
24
|
// One toast however many places notice the ban at once.
|
|
@@ -38,7 +41,30 @@ export const AuthInitializer = ({ children }: AuthInitializerProps): React.React
|
|
|
38
41
|
const pathname = usePathname();
|
|
39
42
|
const router = useAppRouter();
|
|
40
43
|
const dispatch = useAppDispatch();
|
|
41
|
-
const
|
|
44
|
+
const queries = useQueryClient();
|
|
45
|
+
const { signOut } = useSessionTransition();
|
|
46
|
+
const { isLoggingOut, logoutFailed } = useAppSelector((state) => state.auth);
|
|
47
|
+
const reloading = useRef(false);
|
|
48
|
+
|
|
49
|
+
useEffect(
|
|
50
|
+
() => onPeerSessionChange(() => {
|
|
51
|
+
if (reloading.current) return;
|
|
52
|
+
reloading.current = true;
|
|
53
|
+
// Remove the previous screen before requesting a fresh document.
|
|
54
|
+
flushSync(() => clearSessionState(dispatch, queries, true));
|
|
55
|
+
const { pathname: currentPath, search, hash } = window.location;
|
|
56
|
+
if (isProtectedPath(currentPath) && !hasSessionMarker()) {
|
|
57
|
+
const from = new URLSearchParams({ from: currentPath + search + hash });
|
|
58
|
+
window.location.replace(ROUTES.LOGIN + '?' + from);
|
|
59
|
+
} else if (isAuthPath(currentPath) && hasSessionMarker()) {
|
|
60
|
+
const from = new URLSearchParams(search).get('from');
|
|
61
|
+
window.location.replace(getSafeRedirectPath(from) ?? ROUTES.DASHBOARD);
|
|
62
|
+
} else {
|
|
63
|
+
window.location.reload();
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
[dispatch, queries],
|
|
67
|
+
);
|
|
42
68
|
|
|
43
69
|
// The API client reports a session that ended (expired, absent at start-up,
|
|
44
70
|
// or the account banned mid-session; lib/api/session-events.ts). Clear the
|
|
@@ -46,10 +72,14 @@ export const AuthInitializer = ({ children }: AuthInitializerProps): React.React
|
|
|
46
72
|
useEffect(
|
|
47
73
|
() =>
|
|
48
74
|
onSessionEnded((reason) => {
|
|
49
|
-
dispatch
|
|
75
|
+
clearSessionState(dispatch, queries, reason !== 'signed-out');
|
|
76
|
+
if (reason !== 'signed-out') publishSessionChange();
|
|
50
77
|
if (reason === 'deactivated') toast.error(DEACTIVATED_MESSAGE, { id: DEACTIVATED_TOAST_ID });
|
|
78
|
+
if (reason === 'deactivated' || (reason === 'signed-out' && isProtectedPath(window.location.pathname))) {
|
|
79
|
+
window.location.replace(ROUTES.LOGIN);
|
|
80
|
+
}
|
|
51
81
|
}),
|
|
52
|
-
[dispatch]
|
|
82
|
+
[dispatch, queries]
|
|
53
83
|
);
|
|
54
84
|
|
|
55
85
|
// Skip getMe() on auth pages, during logout, and whenever this browser holds
|
|
@@ -58,7 +88,7 @@ export const AuthInitializer = ({ children }: AuthInitializerProps): React.React
|
|
|
58
88
|
// and window focus, enough on a shared IP to hit the refresh rate limit.
|
|
59
89
|
// React Query handles deduping, refetch-on-focus, and invalidation —
|
|
60
90
|
// any mutation that touches the current user (profile update, role change,
|
|
61
|
-
// avatar upload
|
|
91
|
+
// avatar upload) should call:
|
|
62
92
|
// queryClient.invalidateQueries({ queryKey: authKeys.me() })
|
|
63
93
|
// to refresh Redux state automatically.
|
|
64
94
|
const enabled = !isAuthPath(pathname) && !isLoggingOut && hasSessionMarker();
|
|
@@ -83,5 +113,13 @@ export const AuthInitializer = ({ children }: AuthInitializerProps): React.React
|
|
|
83
113
|
}
|
|
84
114
|
}, [error, pathname, router]);
|
|
85
115
|
|
|
116
|
+
if (isLoggingOut) {
|
|
117
|
+
return <main className="p-6" aria-live="polite">
|
|
118
|
+
{logoutFailed
|
|
119
|
+
? <button type="button" onClick={() => void signOut()}>Sign-out failed. Retry sign-out</button>
|
|
120
|
+
: <p>Updating your session…</p>}
|
|
121
|
+
</main>;
|
|
122
|
+
}
|
|
123
|
+
|
|
86
124
|
return <>{children}</>;
|
|
87
125
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useRef } from 'react';
|
|
4
4
|
|
|
5
|
-
import { useMutation
|
|
5
|
+
import { useMutation } from '@tanstack/react-query';
|
|
6
6
|
import { toast } from 'sonner';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { useAppSelector } from '@/store/hooks';
|
|
9
9
|
import { useAppRouter } from '@/hooks/useAppRouter';
|
|
10
10
|
import { getErrorMessage, isErrorCode, isLimitError, ERROR_CODES } from '@/lib/utils/error';
|
|
11
11
|
import { ROUTES } from '@/lib/constants/routes';
|
|
12
12
|
import { getSafeRedirectPath } from '@/lib/utils/security';
|
|
13
13
|
import { authService } from '../services/auth.service';
|
|
14
|
-
import {
|
|
14
|
+
import { useSessionTransition } from './useSessionTransition';
|
|
15
15
|
|
|
16
16
|
import type { ILoginRequest, IRegisterRequest, IUser } from '../types/auth.types';
|
|
17
17
|
|
|
@@ -32,19 +32,15 @@ interface UseAuthReturn {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export const useAuth = (): UseAuthReturn => {
|
|
35
|
-
const dispatch = useAppDispatch();
|
|
36
35
|
const router = useAppRouter();
|
|
37
|
-
const
|
|
36
|
+
const { completeSessionChange, signOut } = useSessionTransition();
|
|
38
37
|
const { user, isAuthenticated, isInitializing, isLoggingOut } = useAppSelector((state) => state.auth);
|
|
39
38
|
const pendingRedirectRef = useRef<string>(ROUTES.DASHBOARD);
|
|
40
39
|
|
|
41
40
|
const loginMutation = useMutation({
|
|
42
41
|
mutationFn: (data: ILoginRequest) => authService.login(data),
|
|
43
|
-
onSuccess: (
|
|
44
|
-
|
|
45
|
-
dispatch(setUser(data.user));
|
|
46
|
-
toast.success('Signed in successfully');
|
|
47
|
-
router.push(pendingRedirectRef.current);
|
|
42
|
+
onSuccess: () => {
|
|
43
|
+
completeSessionChange(pendingRedirectRef.current);
|
|
48
44
|
},
|
|
49
45
|
onError: (error) => {
|
|
50
46
|
// Rate limit / login lock: LoginForm shows it inline (with the wait), no toast.
|
|
@@ -71,10 +67,7 @@ export const useAuth = (): UseAuthReturn => {
|
|
|
71
67
|
router.push(ROUTES.VERIFY_ACCOUNT);
|
|
72
68
|
return;
|
|
73
69
|
}
|
|
74
|
-
|
|
75
|
-
dispatch(setUser(data.user));
|
|
76
|
-
toast.success('Account created successfully');
|
|
77
|
-
router.push(ROUTES.DASHBOARD);
|
|
70
|
+
completeSessionChange(ROUTES.DASHBOARD);
|
|
78
71
|
},
|
|
79
72
|
onError: (error) => {
|
|
80
73
|
// Rate limit / email cap: RegisterForm shows it inline (with the wait), no toast.
|
|
@@ -83,19 +76,6 @@ export const useAuth = (): UseAuthReturn => {
|
|
|
83
76
|
},
|
|
84
77
|
});
|
|
85
78
|
|
|
86
|
-
const logout = useCallback(async (): Promise<void> => {
|
|
87
|
-
dispatch(setLoggingOut(true));
|
|
88
|
-
try {
|
|
89
|
-
await authService.logout();
|
|
90
|
-
} catch {
|
|
91
|
-
// Proceed with local logout even if server call fails
|
|
92
|
-
} finally {
|
|
93
|
-
queryClient.clear();
|
|
94
|
-
dispatch(logoutAction());
|
|
95
|
-
router.push(ROUTES.LOGIN);
|
|
96
|
-
}
|
|
97
|
-
}, [dispatch, router, queryClient]);
|
|
98
|
-
|
|
99
79
|
return {
|
|
100
80
|
user,
|
|
101
81
|
isAuthenticated,
|
|
@@ -103,14 +83,11 @@ export const useAuth = (): UseAuthReturn => {
|
|
|
103
83
|
login: (data: ILoginRequest, redirectTo?: string) => {
|
|
104
84
|
// Validate again at the sink: whatever a caller passes, router.push after
|
|
105
85
|
// login only ever receives a same-site path.
|
|
106
|
-
|
|
107
|
-
if (safeRedirect) {
|
|
108
|
-
pendingRedirectRef.current = safeRedirect;
|
|
109
|
-
}
|
|
86
|
+
pendingRedirectRef.current = getSafeRedirectPath(redirectTo) ?? ROUTES.DASHBOARD;
|
|
110
87
|
loginMutation.mutate(data);
|
|
111
88
|
},
|
|
112
89
|
register: registerMutation.mutate,
|
|
113
|
-
logout,
|
|
90
|
+
logout: signOut,
|
|
114
91
|
isLoggingIn: loginMutation.isPending,
|
|
115
92
|
isRegistering: registerMutation.isPending,
|
|
116
93
|
isLoggingOut,
|
|
@@ -32,15 +32,15 @@ export const useCurrentUser = (
|
|
|
32
32
|
|
|
33
33
|
const { data, isLoading, error } = useQuery({
|
|
34
34
|
queryKey: authKeys.me(),
|
|
35
|
-
queryFn: () => authService.getMe(),
|
|
35
|
+
queryFn: ({ signal }) => authService.getMe(signal),
|
|
36
36
|
enabled,
|
|
37
37
|
staleTime: 30 * 1000,
|
|
38
38
|
retry: false,
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
useEffect(() => {
|
|
42
|
-
if (data) dispatch(setUser(data));
|
|
43
|
-
}, [data, dispatch]);
|
|
42
|
+
if (enabled && data) dispatch(setUser(data));
|
|
43
|
+
}, [enabled, data, dispatch]);
|
|
44
44
|
|
|
45
45
|
useEffect(() => {
|
|
46
46
|
if (!enabled || error) dispatch(setInitialized());
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
5
|
+
import type { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
|
|
7
|
+
import { hardRedirect } from '@/lib/api/hard-redirect';
|
|
8
|
+
import { publishSessionChange, sessionRevision } from '@/lib/api/session-events';
|
|
9
|
+
import { ROUTES } from '@/lib/constants/routes';
|
|
10
|
+
import { useAppDispatch } from '@/store/hooks';
|
|
11
|
+
import type { AppDispatch } from '@/store';
|
|
12
|
+
import { authService } from '../services/auth.service';
|
|
13
|
+
import { blockSession, logout, markLogoutFailed } from '../store/authSlice';
|
|
14
|
+
|
|
15
|
+
/** Clear all account data before the next protected screen can mount. */
|
|
16
|
+
export function clearSessionState(dispatch: AppDispatch, queries: QueryClient, block = false): void {
|
|
17
|
+
void queries.cancelQueries();
|
|
18
|
+
queries.clear();
|
|
19
|
+
dispatch(block ? blockSession() : logout());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useSessionTransition(): {
|
|
23
|
+
completeSessionChange: (path: string) => void;
|
|
24
|
+
signOut: () => Promise<void>;
|
|
25
|
+
} {
|
|
26
|
+
const dispatch = useAppDispatch();
|
|
27
|
+
const queries = useQueryClient();
|
|
28
|
+
|
|
29
|
+
const completeSessionChange = useCallback((path: string): void => {
|
|
30
|
+
clearSessionState(dispatch, queries, true);
|
|
31
|
+
publishSessionChange();
|
|
32
|
+
// The new document boots from the shared cookies. This also discards
|
|
33
|
+
// the Next.js route cache for the previous account.
|
|
34
|
+
hardRedirect(path);
|
|
35
|
+
}, [dispatch, queries]);
|
|
36
|
+
|
|
37
|
+
const signOut = useCallback(async (): Promise<void> => {
|
|
38
|
+
const revision = sessionRevision();
|
|
39
|
+
clearSessionState(dispatch, queries, true);
|
|
40
|
+
try {
|
|
41
|
+
await authService.logout();
|
|
42
|
+
if (revision === sessionRevision()) completeSessionChange(ROUTES.LOGIN);
|
|
43
|
+
} catch {
|
|
44
|
+
// A network failure cannot revoke HttpOnly cookies. Keep this tab
|
|
45
|
+
// blocked and let the user retry before notifying its peers.
|
|
46
|
+
if (revision === sessionRevision()) dispatch(markLogoutFailed());
|
|
47
|
+
}
|
|
48
|
+
}, [completeSessionChange, dispatch, queries]);
|
|
49
|
+
|
|
50
|
+
return { completeSessionChange, signOut };
|
|
51
|
+
}
|
|
@@ -33,9 +33,10 @@ class AuthService {
|
|
|
33
33
|
await apiClient.post(API_ENDPOINTS.AUTH.LOGOUT);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
async getMe(): Promise<IUser> {
|
|
36
|
+
async getMe(signal?: AbortSignal): Promise<IUser> {
|
|
37
37
|
const response = await apiClient.get<ApiResponse<IUser>>(
|
|
38
|
-
API_ENDPOINTS.AUTH.ME
|
|
38
|
+
API_ENDPOINTS.AUTH.ME,
|
|
39
|
+
{ signal },
|
|
39
40
|
);
|
|
40
41
|
return response.data.data;
|
|
41
42
|
}
|
|
@@ -13,6 +13,7 @@ export const initialAuthState: IAuthState = {
|
|
|
13
13
|
isAuthenticated: false,
|
|
14
14
|
isInitializing: true,
|
|
15
15
|
isLoggingOut: false,
|
|
16
|
+
logoutFailed: false,
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
const authSlice = createSlice({
|
|
@@ -24,20 +25,22 @@ const authSlice = createSlice({
|
|
|
24
25
|
state.isAuthenticated = true;
|
|
25
26
|
state.isInitializing = false;
|
|
26
27
|
state.isLoggingOut = false;
|
|
28
|
+
state.logoutFailed = false;
|
|
27
29
|
},
|
|
28
30
|
setInitialized: (state) => {
|
|
29
31
|
state.isInitializing = false;
|
|
30
32
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
state.
|
|
33
|
+
blockSession: () => ({
|
|
34
|
+
...initialAuthState,
|
|
35
|
+
isInitializing: false,
|
|
36
|
+
isLoggingOut: true,
|
|
37
|
+
}),
|
|
38
|
+
markLogoutFailed: (state) => {
|
|
39
|
+
state.logoutFailed = true;
|
|
38
40
|
},
|
|
41
|
+
logout: () => ({ ...initialAuthState, isInitializing: false }),
|
|
39
42
|
},
|
|
40
43
|
});
|
|
41
44
|
|
|
42
|
-
export const { setUser, setInitialized,
|
|
45
|
+
export const { setUser, setInitialized, blockSession, markLogoutFailed, logout } = authSlice.actions;
|
|
43
46
|
export default authSlice.reducer;
|