@erikey/react 0.4.29 → 0.4.31
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/dist/index.d.mts +139 -5
- package/dist/index.mjs +14 -2
- package/dist/index.mjs.map +1 -1
- package/dist/ui/index.mjs +130 -129
- package/dist/ui/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/auth-client.ts +3 -3
- package/src/ui/components/auth/forms/sign-up-form.tsx +14 -2
package/package.json
CHANGED
package/src/auth-client.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import { createAuthClient as createBetterAuthClient } from 'better-auth/react';
|
|
16
|
-
import { siweClient } from 'better-auth/client/plugins';
|
|
16
|
+
import { siweClient, emailOTPClient } from 'better-auth/client/plugins';
|
|
17
17
|
import {
|
|
18
18
|
shouldUseBearerAuth,
|
|
19
19
|
storeToken,
|
|
@@ -145,8 +145,8 @@ export function createAuthClient(config: AuthClientConfig) {
|
|
|
145
145
|
fetchOptions,
|
|
146
146
|
// For same-origin, include cookies (cross-origin uses Bearer from fetchOptions.auth)
|
|
147
147
|
...(!useBearerAuth && { credentials: 'include' as const }),
|
|
148
|
-
// Enable SIWE (Sign-In with Ethereum) support
|
|
149
|
-
plugins: [siweClient()],
|
|
148
|
+
// Enable SIWE (Sign-In with Ethereum) and email OTP support
|
|
149
|
+
plugins: [siweClient(), emailOTPClient()],
|
|
150
150
|
});
|
|
151
151
|
|
|
152
152
|
return client;
|
|
@@ -384,13 +384,25 @@ export function SignUpForm({
|
|
|
384
384
|
fetchOptions
|
|
385
385
|
})
|
|
386
386
|
|
|
387
|
-
|
|
387
|
+
// Check for 2FA redirect first (same pattern as sign-in form)
|
|
388
|
+
if ((data as { twoFactorRedirect?: boolean }).twoFactorRedirect) {
|
|
389
|
+
navigate(
|
|
390
|
+
`${basePath}/${viewPaths.TWO_FACTOR}${window.location.search}`
|
|
391
|
+
)
|
|
392
|
+
} else if ("token" in data && data.token) {
|
|
393
|
+
// Token present = verified or no verification required
|
|
388
394
|
await onSuccess()
|
|
389
|
-
} else if (
|
|
395
|
+
} else if (
|
|
396
|
+
data.user &&
|
|
397
|
+
(data.user as { emailVerified?: boolean }).emailVerified === false
|
|
398
|
+
) {
|
|
399
|
+
// No token + emailVerified: false = needs verification
|
|
400
|
+
// This is response-based (Better Auth pattern), not config-based
|
|
390
401
|
navigate(
|
|
391
402
|
`${basePath}/${viewPaths.EMAIL_VERIFICATION}?email=${encodeURIComponent(email as string)}`
|
|
392
403
|
)
|
|
393
404
|
} else {
|
|
405
|
+
// Fallback: redirect to sign-in (e.g., link-based verification sent)
|
|
394
406
|
navigate(
|
|
395
407
|
`${basePath}/${viewPaths.SIGN_IN}${window.location.search}`
|
|
396
408
|
)
|