@revealui/auth 0.0.1-pre.0
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/LICENSE +202 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js +213 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js +2 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +5 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +482 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +42 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
- package/dist/better-auth/adapter/index.d.ts +15 -0
- package/dist/better-auth/adapter/index.js +731 -0
- package/dist/better-auth/adapter/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/adapter.test.js +174 -0
- package/dist/better-auth/adapter/tests/adapter.test.js.map +1 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js +575 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/index.js +117 -0
- package/dist/better-auth/adapter/tests/dev/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js +26 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js +218 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/schema.js +160 -0
- package/dist/better-auth/adapter/tests/dev/schema.js.map +1 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js +2 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js.map +1 -0
- package/dist/better-auth/adapter/transform/index.d.ts +27 -0
- package/dist/better-auth/adapter/transform/index.js +664 -0
- package/dist/better-auth/adapter/transform/index.js.map +1 -0
- package/dist/better-auth/adapter/types.d.ts +10 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/adapter/types.js.map +1 -0
- package/dist/better-auth/generated-types.d.ts +285 -0
- package/dist/better-auth/index.d.ts +3 -0
- package/dist/better-auth/index.js +5 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js +162 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js.map +1 -0
- package/dist/better-auth/plugin/constants.d.ts +220 -0
- package/dist/better-auth/plugin/constants.js +249 -0
- package/dist/better-auth/plugin/constants.js.map +1 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +12 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js +14 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js.map +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +7 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js +22 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js +20 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts +18 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +70 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js +20 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection.d.ts +15 -0
- package/dist/better-auth/plugin/helpers/get-collection.js +29 -0
- package/dist/better-auth/plugin/helpers/get-collection.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js +65 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js.map +1 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/index.js.map +1 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +59 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +49 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js.map +1 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +20 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +67 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js.map +1 -0
- package/dist/better-auth/plugin/index.d.ts +11 -0
- package/dist/better-auth/plugin/index.js +125 -0
- package/dist/better-auth/plugin/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +12 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +87 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +60 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +154 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +5 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js +11 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js +8 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +119 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js +177 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js +50 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js +59 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +107 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +118 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +89 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js +70 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js +170 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +81 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +111 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js +57 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js +76 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +53 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +75 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js +64 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +80 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +79 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +82 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js +54 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js +15 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js +8 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js +17 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +91 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js +341 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +15 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +24 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +9 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +35 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.d.ts +12 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js +25 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +14 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +20 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +98 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js +87 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +7 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +46 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js +156 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js +18 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js +34 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +7 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js +23 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts +25 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js +62 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +47 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts +15 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +42 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +63 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts +4 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js +14 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +143 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +219 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js +24 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +117 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js +66 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js +52 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js +57 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +22 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js +7 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.d.ts +15 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js +157 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/token-field.js +31 -0
- package/dist/better-auth/plugin/payload/components/token-field.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +300 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/exports/client.js +8 -0
- package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +8 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +10 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +2 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +9 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +22 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +19 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js +226 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js +150 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +16 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js +299 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js +104 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +7 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js +119 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js +78 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js +144 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js +96 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +96 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +56 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js.map +1 -0
- package/dist/better-auth/plugin/types.d.ts +429 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/types.js.map +1 -0
- package/dist/better-auth/plugin/utils/set.d.ts +39 -0
- package/dist/better-auth/plugin/utils/set.js +103 -0
- package/dist/better-auth/plugin/utils/set.js.map +1 -0
- package/dist/better-auth/scripts/generate-types.d.ts +1 -0
- package/dist/better-auth/scripts/generate-types.js +234 -0
- package/dist/better-auth/scripts/generate-types.js.map +1 -0
- package/dist/better-auth/types.d.ts +2 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/better-auth/types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/components/icons.d.ts +7 -0
- package/dist/shared/components/icons.js +442 -0
- package/dist/shared/components/icons.js.map +1 -0
- package/dist/shared/components/logo.d.ts +3 -0
- package/dist/shared/components/logo.js +24 -0
- package/dist/shared/components/logo.js.map +1 -0
- package/dist/shared/form/components/submit.d.ts +7 -0
- package/dist/shared/form/components/submit.js +16 -0
- package/dist/shared/form/components/submit.js.map +1 -0
- package/dist/shared/form/fields/text-field.d.ts +8 -0
- package/dist/shared/form/fields/text-field.js +37 -0
- package/dist/shared/form/fields/text-field.js.map +1 -0
- package/dist/shared/form/index.d.ts +4 -0
- package/dist/shared/form/index.js +8 -0
- package/dist/shared/form/index.js.map +1 -0
- package/dist/shared/form/ui/header/index.d.ts +8 -0
- package/dist/shared/form/ui/header/index.js +24 -0
- package/dist/shared/form/ui/header/index.js.map +1 -0
- package/dist/shared/form/ui/index.d.ts +31 -0
- package/dist/shared/form/ui/index.js +57 -0
- package/dist/shared/form/ui/index.js.map +1 -0
- package/dist/shared/form/validation.d.ts +51 -0
- package/dist/shared/form/validation.js +127 -0
- package/dist/shared/form/validation.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/payload/fields/field-copy-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/field-copy-button/index.js +38 -0
- package/dist/shared/payload/fields/field-copy-button/index.js.map +1 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js +26 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js.map +1 -0
- package/dist/shared/payload/fields/index.d.ts +2 -0
- package/dist/shared/payload/fields/index.js +4 -0
- package/dist/shared/payload/fields/index.js.map +1 -0
- package/dist/shared/utils/regex.d.ts +2 -0
- package/dist/shared/utils/regex.js +4 -0
- package/dist/shared/utils/regex.js.map +1 -0
- package/dist/shared/utils/try-catch.d.ts +11 -0
- package/dist/shared/utils/try-catch.js +17 -0
- package/dist/shared/utils/try-catch.js.map +1 -0
- package/dist/shared/utils/value-or-default.d.ts +9 -0
- package/dist/shared/utils/value-or-default.js +12 -0
- package/dist/shared/utils/value-or-default.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Button, Translation } from "@payloadcms/ui";
|
|
3
|
+
import Link from "next/link";
|
|
4
|
+
import { formatAdminURL } from "payload/shared";
|
|
5
|
+
import React, { Fragment } from "react";
|
|
6
|
+
const FormHeader = ({ heading, description, ...props })=>/*#__PURE__*/ _jsxs("div", {
|
|
7
|
+
className: "form-header",
|
|
8
|
+
...props,
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
11
|
+
children: heading
|
|
12
|
+
}),
|
|
13
|
+
description && /*#__PURE__*/ _jsx("p", {
|
|
14
|
+
children: description
|
|
15
|
+
})
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
import { adminRoutes } from "@/better-auth/plugin/constants";
|
|
19
|
+
import { MinimalTemplate } from "@payloadcms/next/templates";
|
|
20
|
+
import { ForgotPasswordForm } from "./client";
|
|
21
|
+
const ForgotPassword = ({ pluginOptions, initPageResult })=>{
|
|
22
|
+
const { req: { payload: { config: { admin: { routes: { account: accountRoute } }, routes: { admin: adminRoute } } }, user, i18n } } = initPageResult;
|
|
23
|
+
if (user) {
|
|
24
|
+
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
25
|
+
children: [
|
|
26
|
+
/*#__PURE__*/ _jsx(FormHeader, {
|
|
27
|
+
description: /*#__PURE__*/ _jsx(Translation, {
|
|
28
|
+
elements: {
|
|
29
|
+
'0': ({ children })=>/*#__PURE__*/ _jsx(Link, {
|
|
30
|
+
href: formatAdminURL({
|
|
31
|
+
adminRoute,
|
|
32
|
+
path: accountRoute
|
|
33
|
+
}),
|
|
34
|
+
prefetch: false,
|
|
35
|
+
children: children
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
i18nKey: "authentication:loggedInChangePassword",
|
|
39
|
+
t: i18n.t
|
|
40
|
+
}),
|
|
41
|
+
heading: i18n.t('authentication:alreadyLoggedIn')
|
|
42
|
+
}),
|
|
43
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
44
|
+
buttonStyle: "secondary",
|
|
45
|
+
el: "link",
|
|
46
|
+
size: "large",
|
|
47
|
+
to: adminRoute,
|
|
48
|
+
children: i18n.t('general:backToDashboard')
|
|
49
|
+
})
|
|
50
|
+
]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return /*#__PURE__*/ _jsxs(MinimalTemplate, {
|
|
54
|
+
children: [
|
|
55
|
+
(()=>{
|
|
56
|
+
const props = {};
|
|
57
|
+
const baseURL = pluginOptions.betterAuthOptions?.baseURL;
|
|
58
|
+
const basePath = pluginOptions.betterAuthOptions?.basePath;
|
|
59
|
+
if (baseURL) props.baseURL = baseURL;
|
|
60
|
+
if (basePath) props.basePath = basePath;
|
|
61
|
+
return /*#__PURE__*/ _jsx(ForgotPasswordForm, {
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
64
|
+
})(),
|
|
65
|
+
/*#__PURE__*/ _jsx(Link, {
|
|
66
|
+
href: formatAdminURL({
|
|
67
|
+
adminRoute,
|
|
68
|
+
path: adminRoutes.adminLogin
|
|
69
|
+
}),
|
|
70
|
+
prefetch: false,
|
|
71
|
+
children: i18n.t('authentication:backToLogin')
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
export default ForgotPassword;
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/better-auth/plugin/payload/views/forgot-password/index.tsx"],"sourcesContent":["import { Button, Translation } from '@payloadcms/ui';\nimport Link from 'next/link';\nimport type { AdminViewServerProps } from 'payload';\nimport { formatAdminURL } from 'payload/shared';\nimport React, { Fragment } from 'react';\nconst FormHeader = ({\n heading,\n description,\n ...props\n}: { heading: string; description?: React.ReactNode; [key: string]: any }) => (\n <div className='form-header' {...props}>\n <h1>{heading}</h1>\n {description && <p>{description}</p>}\n </div>\n);\nimport { adminRoutes } from '@/better-auth/plugin/constants';\nimport type { BetterAuthPluginOptions } from '@/better-auth/plugin/types';\nimport { MinimalTemplate } from '@payloadcms/next/templates';\nimport { ForgotPasswordForm } from './client';\n\ntype ForgotPasswordProps = AdminViewServerProps & {\n pluginOptions: BetterAuthPluginOptions;\n};\n\nconst ForgotPassword: React.FC<ForgotPasswordProps> = ({ pluginOptions, initPageResult }) => {\n const {\n req: {\n payload: {\n config: {\n admin: {\n routes: { account: accountRoute },\n },\n routes: { admin: adminRoute },\n },\n },\n user,\n i18n,\n },\n } = initPageResult;\n\n if (user) {\n return (\n <Fragment>\n <FormHeader\n description={\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n prefetch={false}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey='authentication:loggedInChangePassword'\n t={i18n.t}\n />\n }\n heading={i18n.t('authentication:alreadyLoggedIn')}\n />\n <Button buttonStyle='secondary' el='link' size='large' to={adminRoute}>\n {i18n.t('general:backToDashboard')}\n </Button>\n </Fragment>\n );\n }\n\n return (\n <MinimalTemplate>\n {(() => {\n const props: any = {};\n const baseURL = pluginOptions.betterAuthOptions?.baseURL;\n const basePath = pluginOptions.betterAuthOptions?.basePath;\n if (baseURL) props.baseURL = baseURL;\n if (basePath) props.basePath = basePath;\n return <ForgotPasswordForm {...props} />;\n })()}\n <Link\n href={formatAdminURL({\n adminRoute,\n path: adminRoutes.adminLogin as `/${string}`,\n })}\n prefetch={false}\n >\n {i18n.t('authentication:backToLogin')}\n </Link>\n </MinimalTemplate>\n );\n};\n\nexport default ForgotPassword;\n"],"names":["Button","Translation","Link","formatAdminURL","React","Fragment","FormHeader","heading","description","props","div","className","h1","p","adminRoutes","MinimalTemplate","ForgotPasswordForm","ForgotPassword","pluginOptions","initPageResult","req","payload","config","admin","routes","account","accountRoute","adminRoute","user","i18n","elements","children","href","path","prefetch","i18nKey","t","buttonStyle","el","size","to","baseURL","betterAuthOptions","basePath","adminLogin"],"mappings":";AAAA,SAASA,MAAM,EAAEC,WAAW,QAAQ,iBAAiB;AACrD,OAAOC,UAAU,YAAY;AAE7B,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAOC,SAASC,QAAQ,QAAQ,Q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P,KAAK;;YACtC,CAAA;0BACA,KAACP;gBACC8B,MAAM7B,eAAe;oBACnBwB;oBACAM,MAAMnB,YAAY8B,UAAU;gBAC9B;gBACAV,UAAU;0BAETL,KAAKO,CAAC,CAAC;;;;AAIhB;AAEA,eAAenB,eAAe"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type PasswordResetFormArgs = {
|
|
3
|
+
readonly token: string;
|
|
4
|
+
readonly minPasswordLength?: number;
|
|
5
|
+
readonly maxPasswordLength?: number;
|
|
6
|
+
readonly baseURL?: string;
|
|
7
|
+
readonly basePath?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare const PasswordResetForm: React.FC<PasswordResetFormArgs>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { Button, toast, useAuth, useConfig, useTranslation } from "@payloadcms/ui";
|
|
5
|
+
import { createAuthClient } from "better-auth/react";
|
|
6
|
+
import { useRouter } from "next/navigation.js";
|
|
7
|
+
import { formatAdminURL } from "payload/shared";
|
|
8
|
+
import React, { useMemo } from "react";
|
|
9
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
export const PasswordResetForm = ({ token, baseURL, basePath })=>{
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const history = useRouter();
|
|
14
|
+
const { fetchFullUser } = useAuth();
|
|
15
|
+
const authClient = useMemo(()=>{
|
|
16
|
+
const options = {};
|
|
17
|
+
if (baseURL) options.baseURL = baseURL;
|
|
18
|
+
if (basePath) options.basePath = basePath;
|
|
19
|
+
return createAuthClient(options);
|
|
20
|
+
}, []);
|
|
21
|
+
const { config: { admin: { routes: { login: loginRoute } }, routes: { admin: adminRoute } } } = useConfig();
|
|
22
|
+
const resetPasswordSchema = z.object({
|
|
23
|
+
password: z.string().min(1, t('validation:required') || 'Password is required'),
|
|
24
|
+
confirmPassword: z.string().min(1, t('validation:required') || 'Confirm password is required')
|
|
25
|
+
}).refine((data)=>{
|
|
26
|
+
// Only validate matching passwords if both fields have values
|
|
27
|
+
if (data.password && data.confirmPassword) {
|
|
28
|
+
return data.password === data.confirmPassword;
|
|
29
|
+
}
|
|
30
|
+
// If one or both fields are empty, validation will be handled by the min(1) validators
|
|
31
|
+
return true;
|
|
32
|
+
}, {
|
|
33
|
+
message: t('fields:passwordsDoNotMatch') || 'Passwords do not match',
|
|
34
|
+
path: [
|
|
35
|
+
'confirmPassword'
|
|
36
|
+
]
|
|
37
|
+
});
|
|
38
|
+
const methods = useForm({
|
|
39
|
+
defaultValues: {
|
|
40
|
+
password: '',
|
|
41
|
+
confirmPassword: ''
|
|
42
|
+
},
|
|
43
|
+
resolver: zodResolver(resetPasswordSchema),
|
|
44
|
+
mode: 'onSubmit'
|
|
45
|
+
});
|
|
46
|
+
const onSubmit = async (data)=>{
|
|
47
|
+
const { password } = data;
|
|
48
|
+
try {
|
|
49
|
+
const { data: responseData, error } = await authClient.resetPassword({
|
|
50
|
+
newPassword: password,
|
|
51
|
+
token
|
|
52
|
+
});
|
|
53
|
+
if (error) {
|
|
54
|
+
toast.error(error.message || 'Error resetting password');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (responseData?.status) {
|
|
58
|
+
const user = await fetchFullUser();
|
|
59
|
+
if (user) {
|
|
60
|
+
history.push(adminRoute);
|
|
61
|
+
} else {
|
|
62
|
+
history.push(formatAdminURL({
|
|
63
|
+
adminRoute,
|
|
64
|
+
path: loginRoute
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
toast.success(t('authentication:passwordResetSuccessfully'));
|
|
68
|
+
}
|
|
69
|
+
} catch (e) {
|
|
70
|
+
toast.error('An unexpected error occurred');
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return /*#__PURE__*/ _jsx(FormProvider, {
|
|
74
|
+
...methods,
|
|
75
|
+
children: /*#__PURE__*/ _jsxs("form", {
|
|
76
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
77
|
+
children: [
|
|
78
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
79
|
+
className: "login__form",
|
|
80
|
+
children: [
|
|
81
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
82
|
+
style: {
|
|
83
|
+
marginBottom: '1rem'
|
|
84
|
+
},
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsx("label", {
|
|
87
|
+
htmlFor: "reset-password-new",
|
|
88
|
+
style: {
|
|
89
|
+
display: 'block',
|
|
90
|
+
marginBottom: '0.5rem'
|
|
91
|
+
},
|
|
92
|
+
children: t('authentication:newPassword')
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx("input", {
|
|
95
|
+
id: "reset-password-new",
|
|
96
|
+
type: "password",
|
|
97
|
+
required: true,
|
|
98
|
+
value: methods.watch('password') ?? '',
|
|
99
|
+
onChange: (e)=>methods.setValue('password', e.target.value),
|
|
100
|
+
style: {
|
|
101
|
+
width: '100%',
|
|
102
|
+
padding: '0.5rem'
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
]
|
|
106
|
+
}),
|
|
107
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
108
|
+
style: {
|
|
109
|
+
marginBottom: '1rem'
|
|
110
|
+
},
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ _jsx("label", {
|
|
113
|
+
htmlFor: "reset-password-confirm",
|
|
114
|
+
style: {
|
|
115
|
+
display: 'block',
|
|
116
|
+
marginBottom: '0.5rem'
|
|
117
|
+
},
|
|
118
|
+
children: t('authentication:confirmPassword')
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ _jsx("input", {
|
|
121
|
+
id: "reset-password-confirm",
|
|
122
|
+
type: "password",
|
|
123
|
+
required: true,
|
|
124
|
+
value: methods.watch('confirmPassword') ?? '',
|
|
125
|
+
onChange: (e)=>methods.setValue('confirmPassword', e.target.value),
|
|
126
|
+
style: {
|
|
127
|
+
width: '100%',
|
|
128
|
+
padding: '0.5rem'
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
}),
|
|
135
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
136
|
+
type: "submit",
|
|
137
|
+
children: t('authentication:resetPassword')
|
|
138
|
+
})
|
|
139
|
+
]
|
|
140
|
+
})
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/better-auth/plugin/payload/views/reset-password/client.tsx"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button, toast, useAuth, useConfig, useTranslation } from '@payloadcms/ui';\nimport { createAuthClient } from 'better-auth/react';\nimport { useRouter } from 'next/navigation.js';\nimport { formatAdminURL } from 'payload/shared';\nimport React, { useMemo } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { z } from 'zod';\n\ntype PasswordResetFormArgs = {\n readonly token: string;\n readonly minPasswordLength?: number;\n readonly maxPasswordLength?: number;\n readonly baseURL?: string;\n readonly basePath?: string;\n};\n\nexport const PasswordResetForm: React.FC<PasswordResetFormArgs> = ({\n token,\n baseURL,\n basePath,\n}) => {\n const { t } = useTranslation();\n const history = useRouter();\n const { fetchFullUser } = useAuth();\n const authClient = useMemo(() => {\n const options: any = {};\n if (baseURL) options.baseURL = baseURL;\n if (basePath) options.basePath = basePath;\n return createAuthClient(options);\n }, []);\n const {\n config: {\n admin: {\n routes: { login: loginRoute },\n },\n routes: { admin: adminRoute },\n },\n } = useConfig();\n\n const resetPasswordSchema = z\n .object({\n password: z.string().min(1, t('validation:required') || 'Password is required'),\n confirmPassword: z\n .string()\n .min(1, t('validation:required') || 'Confirm password is required'),\n })\n .refine(\n data => {\n // Only validate matching passwords if both fields have values\n if (data.password && data.confirmPassword) {\n return data.password === data.confirmPassword;\n }\n // If one or both fields are empty, validation will be handled by the min(1) validators\n return true;\n },\n {\n message: t('fields:passwordsDoNotMatch') || 'Passwords do not match',\n path: ['confirmPassword'],\n }\n );\n\n const methods = useForm({\n defaultValues: {\n password: '',\n confirmPassword: '',\n },\n resolver: zodResolver(resetPasswordSchema),\n mode: 'onSubmit',\n });\n\n const onSubmit = async (data: { password: string; confirmPassword: string }) => {\n const { password } = data;\n try {\n const { data: responseData, error } = await (authClient as any).resetPassword({\n newPassword: password,\n token,\n });\n if (error) {\n toast.error(error.message || 'Error resetting password');\n return;\n }\n if (responseData?.status) {\n const user = await fetchFullUser();\n if (user) {\n history.push(adminRoute);\n } else {\n history.push(\n formatAdminURL({\n adminRoute,\n path: loginRoute,\n })\n );\n }\n toast.success(t('authentication:passwordResetSuccessfully'));\n }\n } catch (e) {\n toast.error('An unexpected error occurred');\n }\n };\n\n return (\n <FormProvider {...methods}>\n <form onSubmit={methods.handleSubmit(onSubmit)}>\n <div className='login__form'>\n <div style={{ marginBottom: '1rem' }}>\n <label\n htmlFor='reset-password-new'\n style={{ display: 'block', marginBottom: '0.5rem' }}\n >\n {t('authentication:newPassword')}\n </label>\n <input\n id='reset-password-new'\n type='password'\n required\n value={(methods.watch('password') as string) ?? ''}\n onChange={(e: any) => methods.setValue('password', e.target.value)}\n style={{ width: '100%', padding: '0.5rem' }}\n />\n </div>\n <div style={{ marginBottom: '1rem' }}>\n <label\n htmlFor='reset-password-confirm'\n style={{ display: 'block', marginBottom: '0.5rem' }}\n >\n {t('authentication:confirmPassword')}\n </label>\n <input\n id='reset-password-confirm'\n type='password'\n required\n value={(methods.watch('confirmPassword') as string) ?? ''}\n onChange={(e: any) => methods.setValue('confirmPassword', e.target.value)}\n style={{ width: '100%', padding: '0.5rem' }}\n />\n </div>\n </div>\n <Button type='submit'>{t('authentication:resetPassword')}</Button>\n </form>\n </FormProvider>\n );\n};\n"],"names":["zodResolver","Button","toast","useAuth","useConfig","useTranslation","createAuthClient","useRouter","formatAdminURL","React","useMemo","FormProvider","useForm","z","PasswordResetForm","token","baseURL","basePath","t","history","fetchFullUser","authClient","options","config","admin","routes","login","loginRoute","adminRoute","resetPasswordSchema","object","password","string","min","confirmPassword","refine","data","message","path","methods","defaultValues","resolver","mode","onSubmit","responseData","error","resetPassword","newPassword","status","user","push","success","e","form","handleSubmit","div","className","style","marginBottom","label","htmlFor","display","input","id","type","required","value","watch","onChange","setValue","target","width","padding"],"mappings":"AAAA;;AAEA,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,MAAM,EAAEC,KAAK,EAAEC,OAAO,EAAEC,SAAS,EAAEC,cAAc,QAAQ,iBAAiB;AACnF,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,QAAQ,qBAAqB;AAC/C,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAOC,SAASC,OAAO,QAAQ,QAAQ;AACvC,SAASC,YAAY,EAAEC,OAAO,QAAQ,kBAAkB;AACxD,SAASC,CAAC,QAAQ,MAAM;AAUxB,OAAO,MAAMC,oBAAqD,CAAC,EACjEC,KAAK,EACLC,OAAO,EACPC,QAAQ,EACT;IACC,MAAM,EAAEC,CAAC,EAAE,GAAGb;IACd,MAAMc,UAAUZ;IAChB,MAAM,EAAEa,aAAa,EAAE,GAAGjB;IAC1B,MAAMkB,aAAaX,QAAQ;QACzB,MAAMY,UAAe,CAAC;QACtB,IAAIN,SAASM,QAAQN,OAAO,GAAGA;QAC/B,IAAIC,UAAUK,QAAQL,QAAQ,GAAGA;QACjC,OAAOX,iBAAiBgB;IAC1B,GAAG,EAAE;IACL,MAAM,EACJC,QAAQ,EACNC,OAAO,EACLC,QAAQ,EAAEC,OAAOC,UAAU,EAAE,EAC9B,EACDF,QAAQ,EAAED,OAAOI,UAAU,EAAE,EAC9B,EAC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YAAY,CAACX;;8BACnC,MAACY;oBAAIC,WAAU;;sCACb,MAACD;4BAAIE,OAAO;gCAAEC,cAAc;4BAAO;;8CACjC,KAACC;oCACCC,SAAQ;oCACRH,OAAO;wCAAEI,SAAS;wCAASH,cAAc;oCAAS;8CAEjDxC,EAAE;;8CAEL,KAAC4C;oCACCC,IAAG;oCACHC,MAAK;oCACLC,QAAQ;oCACRC,OAAO,AAAC3B,QAAQ4B,KAAK,CAAC,eAA0B;oCAChDC,UAAU,CAAChB,IAAWb,QAAQ8B,QAAQ,CAAC,YAAYjB,EAAEkB,MAAM,CAACJ,KAAK;oCACjET,OAAO;wCAAEc,OAAO;wCAAQC,SAAS;oCAAS;;;;sCAG9C,MAACjB;4BAAIE,OAAO;gCAAEC,cAAc;4BAAO;;8CACjC,KAACC;oCACCC,SAAQ;oCACRH,OAAO;wCAAEI,SAAS;wCAASH,cAAc;oCAAS;8CAEjDxC,EAAE;;8CAEL,KAAC4C;oCACCC,IAAG;oCACHC,MAAK;oCACLC,QAAQ;oCACRC,OAAO,AAAC3B,QAAQ4B,KAAK,CAAC,sBAAiC;oCACvDC,UAAU,CAAChB,IAAWb,QAAQ8B,QAAQ,CAAC,mBAAmBjB,EAAEkB,MAAM,CAACJ,KAAK;oCACxET,OAAO;wCAAEc,OAAO;wCAAQC,SAAS;oCAAS;;;;;;8BAIhD,KAACvE;oBAAO+D,MAAK;8BAAU9C,EAAE;;;;;AAIjC,EAAE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdminViewServerProps } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BetterAuthPluginOptions } from '@/better-auth/plugin/types';
|
|
4
|
+
type ResetPasswordProps = AdminViewServerProps & {
|
|
5
|
+
pluginOptions: BetterAuthPluginOptions;
|
|
6
|
+
};
|
|
7
|
+
declare const ResetPassword: React.FC<ResetPasswordProps>;
|
|
8
|
+
export default ResetPassword;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { MinimalTemplate } from "@payloadcms/next/templates";
|
|
3
|
+
import { Button, Link, Translation } from "@payloadcms/ui";
|
|
4
|
+
import { formatAdminURL } from "payload/shared";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
const FormHeader = ({ heading, description, ...props })=>/*#__PURE__*/ _jsxs("div", {
|
|
8
|
+
className: "form-header",
|
|
9
|
+
...props,
|
|
10
|
+
children: [
|
|
11
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
12
|
+
children: heading
|
|
13
|
+
}),
|
|
14
|
+
description && /*#__PURE__*/ _jsx("p", {
|
|
15
|
+
children: description
|
|
16
|
+
})
|
|
17
|
+
]
|
|
18
|
+
});
|
|
19
|
+
import { adminRoutes } from "@/better-auth/plugin/constants";
|
|
20
|
+
import { PasswordResetForm } from "./client";
|
|
21
|
+
const resetPasswordParamsSchema = z.object({
|
|
22
|
+
token: z.string()
|
|
23
|
+
});
|
|
24
|
+
const resetPasswordBaseClass = 'reset-password';
|
|
25
|
+
const ResetPassword = ({ pluginOptions, initPageResult, searchParams })=>{
|
|
26
|
+
const { req: { user, t, payload: { config: { routes: { admin: adminRoute }, admin: { routes: { account: accountRoute } } } } } } = initPageResult;
|
|
27
|
+
if (user) {
|
|
28
|
+
return /*#__PURE__*/ _jsxs(MinimalTemplate, {
|
|
29
|
+
className: `${resetPasswordBaseClass}`,
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ _jsx(FormHeader, {
|
|
32
|
+
description: /*#__PURE__*/ _jsx(Translation, {
|
|
33
|
+
elements: {
|
|
34
|
+
'0': ({ children })=>/*#__PURE__*/ _jsx(Link, {
|
|
35
|
+
href: formatAdminURL({
|
|
36
|
+
adminRoute,
|
|
37
|
+
path: accountRoute
|
|
38
|
+
}),
|
|
39
|
+
prefetch: false,
|
|
40
|
+
children: children
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
i18nKey: "authentication:loggedInChangePassword",
|
|
44
|
+
t: t
|
|
45
|
+
}),
|
|
46
|
+
heading: t('authentication:alreadyLoggedIn')
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
49
|
+
buttonStyle: "secondary",
|
|
50
|
+
el: "link",
|
|
51
|
+
size: "large",
|
|
52
|
+
to: adminRoute,
|
|
53
|
+
children: t('general:backToDashboard')
|
|
54
|
+
})
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const resetPasswordParams = resetPasswordParamsSchema.safeParse(searchParams);
|
|
59
|
+
if (!resetPasswordParams.success) {
|
|
60
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
61
|
+
children: "Invalid reset password params"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const { token } = resetPasswordParams.data;
|
|
65
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
66
|
+
className: `${resetPasswordBaseClass}`,
|
|
67
|
+
children: [
|
|
68
|
+
/*#__PURE__*/ _jsx(FormHeader, {
|
|
69
|
+
heading: t('authentication:resetPassword')
|
|
70
|
+
}),
|
|
71
|
+
(()=>{
|
|
72
|
+
const props = {
|
|
73
|
+
token
|
|
74
|
+
};
|
|
75
|
+
const baseURL = pluginOptions.betterAuthOptions?.baseURL;
|
|
76
|
+
const basePath = pluginOptions.betterAuthOptions?.basePath;
|
|
77
|
+
if (baseURL) props.baseURL = baseURL;
|
|
78
|
+
if (basePath) props.basePath = basePath;
|
|
79
|
+
return /*#__PURE__*/ _jsx(PasswordResetForm, {
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
})(),
|
|
83
|
+
/*#__PURE__*/ _jsx(Link, {
|
|
84
|
+
href: formatAdminURL({
|
|
85
|
+
adminRoute,
|
|
86
|
+
path: adminRoutes.adminLogin
|
|
87
|
+
}),
|
|
88
|
+
prefetch: false,
|
|
89
|
+
children: t('authentication:backToLogin')
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
export default ResetPassword;
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/better-auth/plugin/payload/views/reset-password/index.tsx"],"sourcesContent":["import { MinimalTemplate } from '@payloadcms/next/templates';\nimport { Button, Link, Translation } from '@payloadcms/ui';\nimport type { AdminViewServerProps } from 'payload';\nimport { formatAdminURL } from 'payload/shared';\nimport React from 'react';\nimport { z } from 'zod';\nconst FormHeader = ({\n heading,\n description,\n ...props\n}: { heading: string; description?: React.ReactNode; [key: string]: any }) => (\n <div className='form-header' {...props}>\n <h1>{heading}</h1>\n {description && <p>{description}</p>}\n </div>\n);\nimport { adminRoutes } from '@/better-auth/plugin/constants';\nimport type { BetterAuthPluginOptions } from '@/better-auth/plugin/types';\nimport { PasswordResetForm } from './client';\n\nconst resetPasswordParamsSchema = z.object({\n token: z.string(),\n});\n\nconst resetPasswordBaseClass = 'reset-password';\n\ntype ResetPasswordProps = AdminViewServerProps & {\n pluginOptions: BetterAuthPluginOptions;\n};\n\nconst ResetPassword: React.FC<ResetPasswordProps> = ({\n pluginOptions,\n initPageResult,\n searchParams,\n}) => {\n const {\n req: {\n user,\n t,\n payload: {\n config: {\n routes: { admin: adminRoute },\n admin: {\n routes: { account: accountRoute },\n },\n },\n },\n },\n } = initPageResult;\n\n if (user) {\n return (\n <MinimalTemplate className={`${resetPasswordBaseClass}`}>\n <FormHeader\n description={\n <Translation\n elements={{\n '0': ({ children }) => (\n <Link\n href={formatAdminURL({\n adminRoute,\n path: accountRoute,\n })}\n prefetch={false}\n >\n {children}\n </Link>\n ),\n }}\n i18nKey='authentication:loggedInChangePassword'\n t={t}\n />\n }\n heading={t('authentication:alreadyLoggedIn')}\n />\n <Button buttonStyle='secondary' el='link' size='large' to={adminRoute}>\n {t('general:backToDashboard')}\n </Button>\n </MinimalTemplate>\n );\n }\n\n const resetPasswordParams = resetPasswordParamsSchema.safeParse(searchParams);\n if (!resetPasswordParams.success) {\n return <div>Invalid reset password params</div>;\n }\n const { token } = resetPasswordParams.data;\n\n return (\n <div className={`${resetPasswordBaseClass}`}>\n <FormHeader heading={t('authentication:resetPassword')} />\n {(() => {\n const props: any = { token };\n const baseURL = pluginOptions.betterAuthOptions?.baseURL;\n const basePath = pluginOptions.betterAuthOptions?.basePath;\n if (baseURL) props.baseURL = baseURL;\n if (basePath) props.basePath = basePath;\n return <PasswordResetForm {...props} />;\n })()}\n <Link\n href={formatAdminURL({\n adminRoute,\n path: adminRoutes.adminLogin as `/${string}`,\n })}\n prefetch={false}\n >\n {t('authentication:backToLogin')}\n </Link>\n </div>\n );\n};\n\nexport default ResetPassword;\n"],"names":["MinimalTemplate","Button","Link","Translation","formatAdminURL","React","z","FormHeader","heading","description","props","div","className","h1","p","adminRoutes","PasswordResetForm","resetPasswordParamsSchema","object","token","string","resetPasswordBaseClass","ResetPassword","pluginOptions","initPageResult","searchParams","req","user","t","payload","config","routes","admin","adminRoute","account","accountRoute","elements","children","href","path","prefetch","i18nKey","buttonStyle","el","size","to","resetPasswordParams","safeParse","success","data","baseURL","betterAuthOptions","basePath","adminLogin"],"mappings":";AAAA,SAASA,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,MAAM,EAAEC,IAAI,EAAEC,WAAW,QAAQ,iBAAiB;AAE3D,SAASC,cAAc,QAAQ,iBAAiB;AAChD,OAAOC,WAAW,QAAQ;AAC1B,SAASC,CAAC,QAAQ,MAAM;AACxB,MAAMC,aAAa,CAAC,EAClBC,OAAO,EACPC,WAAW,EACX,GAAGC,OACoE,iBACvE,MAACC;QAAIC,WAAU;QAAe,GAAGF,KAAK;;0BACpC,KAACG;0BAAIL;;YACJC,6BAAe,KAACK;0BAAGL;;;;AAGxB,SAASM,WAAW,QAAQ,iCAAiC;AAE7D,SAASC,iBAAiB,QAAQ,WAAW;AAE7C,MAAMC,4BAA4B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M0C,QAAQ,GAAGA;gBAC/B,qBAAO,KAACpC;oBAAmB,GAAGN,KAAK;;YACrC,CAAA;0BACA,KAACR;gBACCoC,MAAMlC,eAAe;oBACnB6B;oBACAM,MAAMxB,YAAYsC,UAAU;gBAC9B;gBACAb,UAAU;0BAETZ,EAAE;;;;AAIX;AAEA,eAAeN,cAAc"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { zodResolver } from "@hookform/resolvers/zod";
|
|
4
|
+
import { Button, toast, useTranslation } from "@payloadcms/ui";
|
|
5
|
+
import { twoFactorClient } from "better-auth/client/plugins";
|
|
6
|
+
import { createAuthClient } from "better-auth/react";
|
|
7
|
+
import { useRouter } from "next/navigation";
|
|
8
|
+
import { useMemo } from "react";
|
|
9
|
+
import { FormProvider, useForm } from "react-hook-form";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
export const TwoFactorVerifyForm = ({ redirect, twoFactorDigits = 6, baseURL, basePath })=>{
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const router = useRouter();
|
|
14
|
+
const authClient = useMemo(()=>{
|
|
15
|
+
const options = {
|
|
16
|
+
plugins: [
|
|
17
|
+
twoFactorClient()
|
|
18
|
+
]
|
|
19
|
+
};
|
|
20
|
+
if (baseURL) options.baseURL = baseURL;
|
|
21
|
+
if (basePath) options.basePath = basePath;
|
|
22
|
+
return createAuthClient(options);
|
|
23
|
+
}, []);
|
|
24
|
+
const otpSchema = z.object({
|
|
25
|
+
code: z.string().length(twoFactorDigits, `Code must be ${twoFactorDigits} digits`).refine((val)=>/^\d{6}$/.test(val), 'Code must be numeric')
|
|
26
|
+
});
|
|
27
|
+
const methods = useForm({
|
|
28
|
+
defaultValues: {
|
|
29
|
+
code: ''
|
|
30
|
+
},
|
|
31
|
+
resolver: zodResolver(otpSchema),
|
|
32
|
+
mode: 'onSubmit'
|
|
33
|
+
});
|
|
34
|
+
const onSubmit = async (data)=>{
|
|
35
|
+
const { code } = data;
|
|
36
|
+
const { error } = await authClient.twoFactor.verifyTotp({
|
|
37
|
+
code
|
|
38
|
+
});
|
|
39
|
+
if (error) {
|
|
40
|
+
toast.error(error.message);
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
router.push(redirect);
|
|
44
|
+
toast.success('Two-factor verified!');
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/ _jsx(FormProvider, {
|
|
47
|
+
...methods,
|
|
48
|
+
children: /*#__PURE__*/ _jsxs("form", {
|
|
49
|
+
onSubmit: methods.handleSubmit(onSubmit),
|
|
50
|
+
children: [
|
|
51
|
+
/*#__PURE__*/ _jsx("div", {
|
|
52
|
+
className: "form-header",
|
|
53
|
+
style: {
|
|
54
|
+
textAlign: 'center'
|
|
55
|
+
},
|
|
56
|
+
children: /*#__PURE__*/ _jsx("h1", {
|
|
57
|
+
children: "Verify Two-Factor"
|
|
58
|
+
})
|
|
59
|
+
}),
|
|
60
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
61
|
+
style: {
|
|
62
|
+
marginBottom: '1rem'
|
|
63
|
+
},
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ _jsx("label", {
|
|
66
|
+
htmlFor: "two-factor-code",
|
|
67
|
+
style: {
|
|
68
|
+
display: 'block',
|
|
69
|
+
marginBottom: '0.5rem'
|
|
70
|
+
},
|
|
71
|
+
children: "6-digit Code"
|
|
72
|
+
}),
|
|
73
|
+
/*#__PURE__*/ _jsx("input", {
|
|
74
|
+
id: "two-factor-code",
|
|
75
|
+
type: "text",
|
|
76
|
+
required: true,
|
|
77
|
+
autoComplete: "one-time-code",
|
|
78
|
+
value: methods.watch('code') ?? '',
|
|
79
|
+
onChange: (e)=>methods.setValue('code', e.target.value),
|
|
80
|
+
style: {
|
|
81
|
+
width: '100%',
|
|
82
|
+
padding: '0.5rem'
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
]
|
|
86
|
+
}),
|
|
87
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
88
|
+
type: "submit",
|
|
89
|
+
children: t('authentication:verify') || 'Verify'
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/better-auth/plugin/payload/views/two-factor-verify/client.tsx"],"sourcesContent":["'use client';\n\nimport { zodResolver } from '@hookform/resolvers/zod';\nimport { Button, toast, useTranslation } from '@payloadcms/ui';\nimport { twoFactorClient } from 'better-auth/client/plugins';\nimport { createAuthClient } from 'better-auth/react';\nimport { useRouter } from 'next/navigation';\nimport { useMemo } from 'react';\nimport { FormProvider, useForm } from 'react-hook-form';\nimport { z } from 'zod';\n\nexport const TwoFactorVerifyForm = ({\n redirect,\n twoFactorDigits = 6,\n baseURL,\n basePath,\n}: {\n redirect: string;\n twoFactorDigits?: number;\n baseURL?: string;\n basePath?: string;\n}) => {\n const { t } = useTranslation();\n const router = useRouter();\n const authClient = useMemo(() => {\n const options: any = { plugins: [twoFactorClient() as any] };\n if (baseURL) options.baseURL = baseURL;\n if (basePath) options.basePath = basePath;\n return createAuthClient(options);\n }, []);\n\n const otpSchema = z.object({\n code: z\n .string()\n .length(twoFactorDigits, `Code must be ${twoFactorDigits} digits`)\n .refine(val => /^\\d{6}$/.test(val), 'Code must be numeric'),\n });\n\n const methods = useForm({\n defaultValues: { code: '' },\n resolver: zodResolver(otpSchema),\n mode: 'onSubmit',\n });\n\n const onSubmit = async (data: { code: string }) => {\n const { code } = data;\n const { error } = await (authClient as any).twoFactor.verifyTotp({ code });\n if (error) {\n toast.error(error.message);\n return;\n }\n router.push(redirect);\n toast.success('Two-factor verified!');\n };\n\n return (\n <FormProvider {...methods}>\n <form onSubmit={methods.handleSubmit(onSubmit)}>\n <div className='form-header' style={{ textAlign: 'center' }}>\n <h1>Verify Two-Factor</h1>\n </div>\n <div style={{ marginBottom: '1rem' }}>\n <label htmlFor='two-factor-code' style={{ display: 'block', marginBottom: '0.5rem' }}>\n 6-digit Code\n </label>\n <input\n id='two-factor-code'\n type='text'\n required\n autoComplete='one-time-code'\n value={(methods.watch('code') as string) ?? ''}\n onChange={(e: any) => methods.setValue('code', e.target.value)}\n style={{ width: '100%', padding: '0.5rem' }}\n />\n </div>\n <Button type='submit'>{t('authentication:verify') || 'Verify'}</Button>\n </form>\n </FormProvider>\n );\n};\n"],"names":["zodResolver","Button","toast","useTranslation","twoFactorClient","createAuthClient","useRouter","useMemo","FormProvider","useForm","z","TwoFactorVerifyForm","redirect","twoFactorDigits","baseURL","basePath","t","router","authClient","options","plugins","otpSchema","object","code","string","length","refine","val","test","methods","defaultValues","resolver","mode","onSubmit","data","error","twoFactor","verifyTotp","message","push","success","form","handleSubmit","div","className","style","textAlign","h1","marginBottom","label","htmlFor","display","input","id","type","required","autoComplete","value","watch","onChange","e","setValue","target","width","padding"],"mappings":"AAAA;;AAEA,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,MAAM,EAAEC,KAAK,EAAEC,cAAc,QAAQ,iBAAiB;AAC/D,SAASC,eAAe,QAAQ,6BAA6B;AAC7D,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,OAAO,QAAQ,QAAQ;AAChC,SAASC,YAAY,EAAEC,OAAO,QAAQ,kBAAkB;AACxD,SAASC,CAAC,QAAQ,MAAM;AAExB,OAAO,MAAMC,sBAAsB,CAAC,EAClCC,QAAQ,EACRC,kBAAkB,CAAC,EACnBC,OAAO,EACPC,QAAQ,EAMT;IACC,MAAM,EAAEC,CAAC,EAAE,GAAGb;IACd,MAAMc,SAASX;IACf,MAAMY,aAAaX,QAAQ;QACzB,MAAMY,UAAe;YAAEC,SAAS;gBAAChB;aAAyB;QAAC;QAC3D,IAAIU,SA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KAAK;4BAC7DZ,OAAO;gCAAEkB,OAAO;gCAAQC,SAAS;4BAAS;;;;8BAG9C,KAAC/D;oBAAOqD,MAAK;8BAAUtC,EAAE,4BAA4B;;;;;AAI7D,EAAE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AdminViewServerProps } from 'payload';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BetterAuthPluginOptions } from '@/better-auth/plugin/types';
|
|
4
|
+
interface TwoFactorVerifyProps extends AdminViewServerProps {
|
|
5
|
+
pluginOptions: BetterAuthPluginOptions;
|
|
6
|
+
verificationsSlug: string;
|
|
7
|
+
}
|
|
8
|
+
declare const TwoFactorVerify: React.FC<TwoFactorVerifyProps>;
|
|
9
|
+
export default TwoFactorVerify;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cookies } from "next/headers";
|
|
3
|
+
import { redirect } from "next/navigation";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import { getSafeRedirect } from "../../utils/get-safe-redirect";
|
|
6
|
+
import { TwoFactorVerifyForm } from "./client";
|
|
7
|
+
const valueOrDefaultString = (value, defaultValue)=>value ?? defaultValue;
|
|
8
|
+
import { adminRoutes, supportedBAPluginIds } from "@/better-auth/plugin/constants";
|
|
9
|
+
import { MinimalTemplate } from "@payloadcms/next/templates";
|
|
10
|
+
const TwoFactorVerify = async ({ searchParams, initPageResult, pluginOptions, verificationsSlug })=>{
|
|
11
|
+
const { req } = initPageResult;
|
|
12
|
+
const { payload: { config }, payload } = req;
|
|
13
|
+
const { admin: { routes: { login } }, routes: { admin: adminRoute } } = config;
|
|
14
|
+
const cookieStore = await cookies();
|
|
15
|
+
const loginRoute = valueOrDefaultString(login, adminRoutes.adminLogin);
|
|
16
|
+
const redirectUrl = getSafeRedirect(searchParams?.redirect ?? '', adminRoute);
|
|
17
|
+
const twoFactorOptions = pluginOptions.betterAuthOptions?.plugins?.find((plugin)=>plugin.id === supportedBAPluginIds.twoFactor)?.options ?? {};
|
|
18
|
+
const twoFactorCookie = cookieStore.get(`${process.env.NODE_ENV === 'production' ? '__Secure-' : ''}better-auth.two_factor`)?.value;
|
|
19
|
+
if (!twoFactorCookie) {
|
|
20
|
+
redirect(`${adminRoute}${loginRoute}`);
|
|
21
|
+
}
|
|
22
|
+
const twoFactorVerifyToken = twoFactorCookie.split('.').at(0);
|
|
23
|
+
if (!twoFactorVerifyToken) {
|
|
24
|
+
redirect(`${adminRoute}${loginRoute}`);
|
|
25
|
+
}
|
|
26
|
+
const { totalDocs: isValidTwoFactorToken } = await payload.count({
|
|
27
|
+
collection: verificationsSlug,
|
|
28
|
+
where: {
|
|
29
|
+
identifier: {
|
|
30
|
+
equals: twoFactorVerifyToken
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (!isValidTwoFactorToken) {
|
|
35
|
+
redirect(`${adminRoute}${loginRoute}`);
|
|
36
|
+
}
|
|
37
|
+
return /*#__PURE__*/ _jsx(MinimalTemplate, {
|
|
38
|
+
className: "two-factor-verify",
|
|
39
|
+
children: (()=>{
|
|
40
|
+
const props = {
|
|
41
|
+
redirect: redirectUrl
|
|
42
|
+
};
|
|
43
|
+
if (twoFactorOptions?.totpOptions?.digits) props.twoFactorDigits = twoFactorOptions.totpOptions.digits;
|
|
44
|
+
const baseURL = pluginOptions.betterAuthOptions?.baseURL;
|
|
45
|
+
const basePath = pluginOptions.betterAuthOptions?.basePath;
|
|
46
|
+
if (baseURL) props.baseURL = baseURL;
|
|
47
|
+
if (basePath) props.basePath = basePath;
|
|
48
|
+
return /*#__PURE__*/ _jsx(TwoFactorVerifyForm, {
|
|
49
|
+
...props
|
|
50
|
+
});
|
|
51
|
+
})()
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
export default TwoFactorVerify;
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/better-auth/plugin/payload/views/two-factor-verify/index.tsx"],"sourcesContent":["import { cookies } from 'next/headers';\nimport { redirect } from 'next/navigation';\nimport type { AdminViewServerProps } from 'payload';\nimport React from 'react';\nimport { getSafeRedirect } from '../../utils/get-safe-redirect';\nimport { TwoFactorVerifyForm } from './client';\nconst valueOrDefaultString = (value: string | undefined, defaultValue: string): string =>\n value ?? defaultValue;\nimport { adminRoutes, supportedBAPluginIds } from '@/better-auth/plugin/constants';\nimport type { BetterAuthPluginOptions } from '@/better-auth/plugin/types';\nimport { MinimalTemplate } from '@payloadcms/next/templates';\n\ninterface TwoFactorVerifyProps extends AdminViewServerProps {\n pluginOptions: BetterAuthPluginOptions;\n verificationsSlug: string;\n}\n\nconst TwoFactorVerify: React.FC<TwoFactorVerifyProps> = async ({\n searchParams,\n initPageResult,\n pluginOptions,\n verificationsSlug,\n}) => {\n const { req } = initPageResult;\n const {\n payload: { config },\n payload,\n } = req;\n\n const {\n admin: {\n routes: { login },\n },\n routes: { admin: adminRoute },\n } = config;\n const cookieStore = await cookies();\n const loginRoute = valueOrDefaultString(login, adminRoutes.adminLogin);\n const redirectUrl = getSafeRedirect((searchParams?.redirect as string) ?? '', adminRoute);\n\n const twoFactorOptions =\n pluginOptions.betterAuthOptions?.plugins?.find(\n plugin => plugin.id === supportedBAPluginIds.twoFactor\n )?.options ?? {};\n\n const twoFactorCookie = cookieStore.get(\n `${process.env.NODE_ENV === 'production' ? '__Secure-' : ''}better-auth.two_factor`\n )?.value;\n if (!twoFactorCookie) {\n redirect(`${adminRoute}${loginRoute}`);\n }\n const twoFactorVerifyToken = twoFactorCookie.split('.').at(0);\n if (!twoFactorVerifyToken) {\n redirect(`${adminRoute}${loginRoute}`);\n }\n const { totalDocs: isValidTwoFactorToken } = await payload.count({\n collection: verificationsSlug as any,\n where: {\n identifier: {\n equals: twoFactorVerifyToken,\n },\n },\n });\n if (!isValidTwoFactorToken) {\n redirect(`${adminRoute}${loginRoute}`);\n }\n\n return (\n <MinimalTemplate className='two-factor-verify'>\n {(() => {\n const props: any = {\n redirect: redirectUrl,\n };\n if ((twoFactorOptions as any)?.totpOptions?.digits)\n props.twoFactorDigits = (twoFactorOptions as any).totpOptions.digits;\n const baseURL = pluginOptions.betterAuthOptions?.baseURL;\n const basePath = pluginOptions.betterAuthOptions?.basePath;\n if (baseURL) props.baseURL = baseURL;\n if (basePath) props.basePath = basePath;\n return <TwoFactorVerifyForm {...props} />;\n })()}\n </MinimalTemplate>\n );\n};\n\nexport default TwoFactorVerify;\n"],"names":["cookies","redirect","React","getSafeRedirect","TwoFactorVerifyForm","valueOrDefaultString","value","defaultValue","adminRoutes","supportedBAPluginIds","MinimalTemplate","TwoFactorVerify","searchParams","initPageResult","pluginOptions","verificationsSlug","req","payload","config","admin","routes","login","adminRoute","cookieStore","loginRoute","adminLogin","redirectUrl","twoFactorOptions","betterAuthOptions","plugins","find","plugin","id","twoFactor","options","twoFactorCookie","get","process","env","NODE_ENV","twoFactorVerifyToken","split","at","totalDocs","isValidTwoFactorToken","count","collection","where","identifier","equals","className","props","totpOptions","digits","twoFactorDigits","baseURL","basePath"],"mappings":";AAAA,SAASA,OAAO,QAAQ,eAAe;AACvC,SAASC,QAAQ,QAAQ,kBAAkB;AAE3C,OAAOC,WAAW,QAAQ;AAC1B,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,MAAMC,uBAAuB,CAACC,OAA2BC,eACvDD,SAASC;AACX,SAASC,WAAW,EAAEC,oBAAoB,QAAQ,iCAAiC;AAEnF,SAASC,eAAe,QAAQ,6BAA6B;AAO7D,MAAMC,kBAAkD,OAAO,EAC7DC,YAAY,EACZC,cAAc,EACdC,aAAa,EACbC,iBAAiB,EAClB;IACC,MAAM,EAAEC,GAAG,EAAE,GAAGH;IAChB,MAAM,EACJI,SAAS,EAAEC,MAAM,EAAE,EACnBD,OAAO,EACR,GAAGD;IAEJ,MAAM,EACJG,OAA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