cloudflare-next-intl 0.7.5 → 0.7.7
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/README.md
CHANGED
|
@@ -253,9 +253,11 @@ Set `firebaseAuth` on your `RoutingConfig` to enable — `IntlProvider` then
|
|
|
253
253
|
auto-wires `AuthUserProvider` and server-side `getAuthUser` session validation.
|
|
254
254
|
|
|
255
255
|
Features include:
|
|
256
|
+
- `whiteListPaths`: Array of paths exempt from auth redirects (matches exact path or path-segment prefix, e.g. `/bonds` matches `/bonds/some-slug`).
|
|
257
|
+
- `actionLinkPath`: Pinned route for handling Firebase action links (e.g. `/auth/action`), prioritized during cross-origin action link redirects.
|
|
256
258
|
- `createForgotPasswordAction(locale, actionCodeSettings?)`: Accepts optional Firebase `AuthActionCodeSettings` (e.g. `url` redirect link).
|
|
257
259
|
- `sendVerificationEmail(actionCodeSettings?)` on `useAuthUser()`: Custom action email settings when resending email verification.
|
|
258
|
-
- `followSameOriginContinueUrl`: Automatically forwards emailed action links with `continueUrl` to the specified path (or external URL) directly from `intlMiddleware` (default `true`; set `false` on `firebaseAuth` config to disable). If `continueUrl` points to home root (`/`), it resolves to the mode target path (e.g. `/reset-password`).
|
|
260
|
+
- `followSameOriginContinueUrl`: Automatically forwards emailed action links with `continueUrl` to the specified path (or external URL) directly from `intlMiddleware` (default `true`; set `false` on `firebaseAuth` config to disable). If `continueUrl` points to home root (`/`), it resolves to `actionLinkPath` (if set) or the mode target path (e.g. `/reset-password`).
|
|
259
261
|
|
|
260
262
|
```tsx
|
|
261
263
|
import ThemeSwitcher from "cloudflare-next-intl/ThemeSwitcher";
|
|
@@ -327,9 +327,15 @@ export default function AuthUserProvider({ initialUser = null, children }) {
|
|
|
327
327
|
}
|
|
328
328
|
finally {
|
|
329
329
|
await clearSession(sessionCookieName, refreshTokenCookieName, emailVerifiedHintCookieName, appCheckTokenCookieName, refreshTokenMaxAge);
|
|
330
|
-
|
|
330
|
+
// Whitelisted paths opt out of every other auth redirect in this
|
|
331
|
+
// provider (see the effect above), so an explicit `logout()` from
|
|
332
|
+
// one must not bounce either — a page like a delete-account flow
|
|
333
|
+
// signs the user out as a STEP and still needs to render its own
|
|
334
|
+
// result afterwards.
|
|
335
|
+
if (!isWhiteListed)
|
|
336
|
+
router.push(fa.redirectAuthPath);
|
|
331
337
|
}
|
|
332
338
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
333
|
-
}, [fa.redirectAuthPath, sessionCookieName, refreshTokenCookieName, emailVerifiedHintCookieName, appCheckTokenCookieName]);
|
|
339
|
+
}, [fa.redirectAuthPath, sessionCookieName, refreshTokenCookieName, emailVerifiedHintCookieName, appCheckTokenCookieName, isWhiteListed]);
|
|
334
340
|
return _jsx(AuthUserContext.Provider, { value: { ...state, reloadUser, sendVerificationEmail, logout }, children: children });
|
|
335
341
|
}
|
|
@@ -6,6 +6,7 @@ import config from '@intl-config';
|
|
|
6
6
|
import requireFirebaseAuthConfig from '../require_config';
|
|
7
7
|
import { getAuthenticatedAppForUser } from './firebase_server';
|
|
8
8
|
import withRedirectQuery from '../preserve_redirect_query';
|
|
9
|
+
import isWhitelisted from '../is_whitelisted';
|
|
9
10
|
const AuthUserProvider = dynamic(() => import('../client/auth_user_provider'));
|
|
10
11
|
/**
|
|
11
12
|
* Resolves the signed-in user from the session cookie and performs the
|
|
@@ -29,7 +30,7 @@ export async function resolveAuthUserAndRedirect() {
|
|
|
29
30
|
const requestHeaders = await headers();
|
|
30
31
|
const path = requestHeaders.get('x-pathname') ?? '/';
|
|
31
32
|
const isAuthPage = fa.isAuthPath(path);
|
|
32
|
-
const isWhiteListed = fa.whiteListPaths
|
|
33
|
+
const isWhiteListed = isWhitelisted(path, fa.whiteListPaths);
|
|
33
34
|
// `x-pathname` is path-only, so the query string comes from `x-search`
|
|
34
35
|
// (set alongside it by `intlMiddleware`) — `redirect()` takes a plain
|
|
35
36
|
// string, not a URL.
|