@baseplate-dev/plugin-auth 0.6.16 → 0.6.18
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 +36 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +12 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +12 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +6 -0
- package/dist/better-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +6 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +12 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +12 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +6 -0
- package/dist/better-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +12 -0
- package/dist/better-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +6 -0
- package/dist/better-auth/generators/react/better-auth-pages/better-auth-pages.generator.d.ts +6 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/index.d.ts +36 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/template-renderers.d.ts +6 -0
- package/dist/better-auth/generators/react/better-auth-pages/generated/typed-templates.d.ts +60 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/index.d.ts +12 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/template-renderers.d.ts +6 -0
- package/dist/better-auth/generators/react/react-better-auth/generated/typed-templates.d.ts +6 -0
- package/dist/better-auth/generators/react/react-better-auth/react-better-auth.generator.d.ts +6 -0
- package/dist/local-auth/admin/common.js +6 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.d.ts +531 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/admin-crud-invite-user-action.generator.js +119 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.d.ts +540 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/index.js +11 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-paths.js +24 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.d.ts +276 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/template-renderers.js +45 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.d.ts +263 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/generated/typed-templates.js +21 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.d.ts +2 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/index.js +2 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.d.ts +21 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.js +69 -0
- package/dist/local-auth/admin/generators/admin-crud-invite-user-action/templates/routes/-components/invite-user-dialog.tsx +122 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/admin-crud-manage-roles-action.generator.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/index.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/template-renderers.d.ts +6 -0
- package/dist/local-auth/admin/generators/admin-crud-manage-roles-action/generated/typed-templates.d.ts +6 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/admin-crud-reset-password-action.generator.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/index.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/template-renderers.d.ts +6 -0
- package/dist/local-auth/admin/generators/admin-crud-reset-password-action/generated/typed-templates.d.ts +12 -0
- package/dist/local-auth/admin/generators/admin-crud-roles-column/admin-crud-roles-column.generator.d.ts +6 -0
- package/dist/local-auth/admin/node.js +13 -0
- package/dist/local-auth/admin/schema/invite-user-action.d.ts +12 -0
- package/dist/local-auth/admin/schema/invite-user-action.js +6 -0
- package/dist/local-auth/admin/web.js +8 -0
- package/dist/local-auth/core/common.js +7 -2
- package/dist/local-auth/core/components/local-auth-definition-editor.js +2 -1
- package/dist/local-auth/core/components/local-auth-web-app-settings-form.d.ts +9 -0
- package/dist/local-auth/core/components/local-auth-web-app-settings-form.js +11 -0
- package/dist/local-auth/core/generators/auth-apollo/auth-apollo.generator.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.d.ts +6 -0
- package/dist/local-auth/core/generators/auth-email-password/auth-email-password.generator.js +66 -6
- package/dist/local-auth/core/generators/auth-email-password/generated/index.d.ts +188 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.d.ts +5 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-paths.js +5 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.d.ts +18 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/template-renderers.js +66 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.d.ts +192 -0
- package/dist/local-auth/core/generators/auth-email-password/generated/typed-templates.js +82 -1
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.d.ts +19 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.js +20 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/otp.constants.ts +22 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.d.ts +12 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.js +12 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/constants/password.constants.ts +14 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.js +30 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/email-otp.mutations.ts +38 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.js +42 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/invite.mutations.ts +54 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.js +2 -19
- package/dist/local-auth/core/generators/auth-email-password/templates/module/schema/user-password.mutations.ts +1 -22
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.d.ts +37 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.js +225 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/email-otp.service.ts +333 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.d.ts +39 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.js +138 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/invite.service.ts +209 -0
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.js +3 -3
- package/dist/local-auth/core/generators/auth-email-password/templates/module/services/password-reset.service.ts +3 -2
- package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.d.ts +3 -1
- package/dist/local-auth/core/generators/auth-email-templates/auth-email-templates.generator.js +18 -3
- package/dist/local-auth/core/generators/auth-email-templates/generated/index.d.ts +40 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.d.ts +2 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-paths.js +2 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.d.ts +6 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/template-renderers.js +20 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.d.ts +40 -0
- package/dist/local-auth/core/generators/auth-email-templates/generated/typed-templates.js +24 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.js +18 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/email-otp.email.tsx +57 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.js +14 -0
- package/dist/local-auth/core/generators/auth-email-templates/templates/src/emails/auth/invite.email.tsx +47 -0
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.d.ts +8 -0
- package/dist/local-auth/core/generators/auth-module/auth-module.generator.js +5 -1
- package/dist/local-auth/core/generators/auth-module/generated/index.d.ts +32 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.d.ts +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-paths.js +1 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-module/generated/template-renderers.js +13 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-module/generated/ts-import-providers.js +6 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.d.ts +25 -0
- package/dist/local-auth/core/generators/auth-module/generated/typed-templates.js +20 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.d.ts +4 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.js +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/auth-verification.service.ts +1 -1
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.d.ts +66 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.js +134 -0
- package/dist/local-auth/core/generators/auth-module/templates/module/services/code-verification.service.ts +184 -0
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.d.ts +8 -0
- package/dist/local-auth/core/generators/auth-routes/auth-routes.generator.js +38 -5
- package/dist/local-auth/core/generators/auth-routes/generated/index.d.ts +840 -268
- package/dist/local-auth/core/generators/auth-routes/generated/template-paths.d.ts +3 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-paths.js +3 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.d.ts +18 -0
- package/dist/local-auth/core/generators/auth-routes/generated/template-renderers.js +51 -0
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.d.ts +608 -283
- package/dist/local-auth/core/generators/auth-routes/generated/typed-templates.js +69 -23
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.d.ts +9 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.js +10 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.ts +11 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.js +148 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/accept-invite.tsx +264 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.d.ts +7 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.js +184 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login-otp.tsx +311 -0
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.js +1 -1
- package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/login.tsx +2 -9
- package/dist/local-auth/core/generators/react-session/generated/index.d.ts +12 -0
- package/dist/local-auth/core/generators/react-session/generated/template-renderers.d.ts +6 -0
- package/dist/local-auth/core/generators/react-session/generated/typed-templates.d.ts +12 -0
- package/dist/local-auth/core/generators/react-session/react-session.generator.d.ts +6 -0
- package/dist/local-auth/core/node.js +24 -6
- package/dist/local-auth/core/schema/migrations.d.ts +3 -0
- package/dist/local-auth/core/schema/migrations.js +36 -0
- package/dist/local-auth/core/schema/models.js +8 -0
- package/dist/local-auth/core/schema/plugin-definition.d.ts +1 -0
- package/dist/local-auth/core/schema/plugin-definition.js +1 -0
- package/dist/local-auth/core/schema/web-app-schema.d.ts +15 -0
- package/dist/local-auth/core/schema/web-app-schema.js +16 -0
- package/dist/local-auth/core/web.js +8 -1
- package/dist/web/assets/{_virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth-04_7KkB1.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth__mf_owner__1-CKKmnLep.js} +49 -41
- package/dist/web/assets/{dist-BjxypexQ.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-Cx7TvZ_H.js} +16720 -384
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-D3Nvasea.js +177 -0
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-CXGct_48.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_baseplate_mf_2_dev_mf_1_ui_mf_2_components__loadShare__.js-C2GDE8Py.js} +3349 -2632
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-Ci5_qYaj.js → _virtual_mf___mfe_internal__plugin_mf_2_auth__mf_owner__1__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-CiccpWjh.js} +320 -164
- package/dist/web/assets/{arduino-BP2nYunF.js → arduino-BXtgMpyb.js} +2 -2
- package/dist/web/assets/auth-CsHp2bQi.js +1 -0
- package/dist/web/assets/{c-C7Ey31hW.js → c-6gdx-Hqg.js} +3 -3
- package/dist/web/assets/{clike-D9YNFwtw.js → clike-Ds9lUsCq.js} +2 -2
- package/dist/web/assets/common-BGTuTgx7.js +43 -0
- package/dist/web/assets/common-C8_sC5pp.js +70 -0
- package/dist/web/assets/{common-BvU-7KsV.js → common-Co5lW_TK.js} +13 -11
- package/dist/web/assets/{common-eFh2vwGb.js → common-CoLuMS7U.js} +6 -6
- package/dist/web/assets/common-Dueu_1NG.js +36 -0
- package/dist/web/assets/{common-BBriDRRy.js → common-N3skPbzk.js} +10 -10
- package/dist/web/assets/{cpp-_RjA_yNA.js → cpp-DRYAY5P6.js} +2 -2
- package/dist/web/assets/{csharp-0LZzOc6Q.js → csharp-RJBSoHJ6.js} +2 -2
- package/dist/web/assets/{dist-SBfmsOB2.js → dist-DQd1TAJX.js} +274 -133
- package/dist/web/assets/{get-auth-plugin-definition-x8oAsN1R.js → get-auth-plugin-definition-DyokUVjX.js} +3 -3
- package/dist/web/assets/{go-CzER04EZ.js → go-D9nlw8GJ.js} +2 -2
- package/dist/web/assets/{hostInit-Bay0Y9UX.js → hostInit-BCYmw0H5.js} +33 -6
- package/dist/web/assets/{java-HAvRESj1.js → java-Asfw0WtJ.js} +2 -2
- package/dist/web/assets/{javascript-BVAr0eZH.js → javascript-fpnGEVws.js} +2 -2
- package/dist/web/assets/{kotlin-DkCMjTKK.js → kotlin-zNWfDPVY.js} +2 -2
- package/dist/web/assets/{markdown-_2_uVr2L.js → markdown-ewV-vLcZ.js} +2 -2
- package/dist/web/assets/{markup-BVZ8HhdW.js → markup-D2krQlDZ.js} +2 -2
- package/dist/web/assets/{markup-templating-BDIRuVJH.js → markup-templating-c_XBo6vX.js} +2 -2
- package/dist/web/assets/mf-entry-bootstrap-0-3ede9334.js +36 -0
- package/dist/web/assets/mf-entry-bootstrap-1-3da85eea.js +36 -0
- package/dist/web/assets/{mf-entry-bootstrap-0-659c976f.js → mf-entry-bootstrap-2-32e24e11.js} +3 -2
- package/dist/web/assets/mf-entry-bootstrap-3-a3cfea9d.js +36 -0
- package/dist/web/assets/{models-BpslIbU7.js → models-BcPOQC5p.js} +4 -5
- package/dist/web/assets/{models-CKab4MTC.js → models-BcUgOGGn.js} +11 -6
- package/dist/web/assets/{objectivec-DPgB68It.js → objectivec-PkUOhxeb.js} +2 -2
- package/dist/web/assets/{php-JTON0zp9.js → php-CfWLJZIj.js} +2 -2
- package/dist/web/assets/{plugin-definition-8Exesd6T.js → plugin-definition-D1EImXIf.js} +9 -10
- package/dist/web/assets/plugin-definition-lw-gB4hU.js +10 -0
- package/dist/web/assets/{rolldown-runtime-FZ4Itg2g.js → rolldown-runtime-7_rZTKki.js} +1 -1
- package/dist/web/assets/{ruby-BoFHz67P.js → ruby-BlM93DKO.js} +2 -2
- package/dist/web/assets/{styles-Cc26Bbxc.css → styles-DIj1cIPB.css} +119 -1
- package/dist/web/assets/{styles-Cuq4wgvD.js → styles-EOyEbGA4.js} +9 -10
- package/dist/web/assets/{typescript-CDkIWcT8.js → typescript-C5BVqltI.js} +2 -2
- package/dist/web/assets/{virtualExposes-BwIds34r.js → virtualExposes-DWORnjyA.js} +1 -1
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-t-KnBiUh.js +747 -0
- package/dist/web/assets/{virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DM6Ir1_S.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DZfE3QCR.js} +15 -15
- package/dist/web/assets/{vite-preload-helper-iIio8xkS.js → vite-preload-helper-ARKYL6bp.js} +5 -1
- package/dist/web/assets/{web-DHv2aVpi.js → web-CBVepebK.js} +24 -24
- package/dist/web/assets/{web-CnB-sqCR.js → web-Dgb85jhs.js} +54 -53
- package/dist/web/assets/{web-BZd3bM0n.js → web-EDeSquSP.js} +38 -38
- package/dist/web/assets/{web-DNrWXjpS.js → web-PqAcfBSy.js} +9 -9
- package/dist/web/assets/{web-BgWG7dYl.js → web-RhChfBw_.js} +23 -23
- package/dist/web/assets/web-kaD9AzNS.js +59 -0
- package/dist/web/assets/web-xJ-GnSkC.js +148 -0
- package/dist/web/assets/{workerBundle-GFUata9j.js → workerBundle-BjsY-uXx.js} +2 -2
- package/dist/web/index.html +5 -2
- package/dist/web/remoteEntry.js +1 -1
- package/package.json +36 -39
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib__loadShare__.js-BfSk5vRC.js +0 -384
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_baseplate_mf_2_dev_mf_1_project_mf_2_builder_mf_2_lib_mf_1_web__loadShare__.js-DZIcwf2B.js +0 -125
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-Do-7VDVw.js +0 -13567
- package/dist/web/assets/auth-8qJtXAgU.js +0 -1
- package/dist/web/assets/common-23-wvKrM.js +0 -39
- package/dist/web/assets/common-B-NI9TR-.js +0 -37
- package/dist/web/assets/common-DBBUvtGu.js +0 -37
- package/dist/web/assets/index-qso1IsKy.js +0 -2
- package/dist/web/assets/model-utils-dNFTOjqi.js +0 -1599
- package/dist/web/assets/plugin-definition-ChBrbazJ.js +0 -11
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-BBt5f0I7.js +0 -259
- package/dist/web/assets/virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-RzPgl37a.js +0 -129
- package/dist/web/assets/web-CXHw8SK7.js +0 -118
- package/dist/web/assets/web-D_H-MoGI.js +0 -46
- package/dist/web/remoteEntry.ssr.js +0 -43
|
@@ -2,6 +2,38 @@ import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
|
2
2
|
import { apolloErrorImportsProvider, graphqlImportsProvider, reactComponentsImportsProvider, reactErrorImportsProvider, } from '@baseplate-dev/react-generators';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { reactSessionImportsProvider } from '#src/local-auth/core/generators/react-session/generated/ts-import-providers.js';
|
|
5
|
+
const acceptInvite = createTsTemplateFile({
|
|
6
|
+
fileOptions: { kind: 'singleton' },
|
|
7
|
+
importMapProviders: {
|
|
8
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
9
|
+
graphqlImports: graphqlImportsProvider,
|
|
10
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
11
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
12
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
13
|
+
},
|
|
14
|
+
name: 'accept-invite',
|
|
15
|
+
referencedGeneratorTemplates: { constants: {} },
|
|
16
|
+
source: {
|
|
17
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/accept-invite.tsx'),
|
|
18
|
+
},
|
|
19
|
+
variables: {},
|
|
20
|
+
});
|
|
21
|
+
const loginOtp = createTsTemplateFile({
|
|
22
|
+
fileOptions: { kind: 'singleton' },
|
|
23
|
+
importMapProviders: {
|
|
24
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
25
|
+
graphqlImports: graphqlImportsProvider,
|
|
26
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
27
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
28
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
29
|
+
},
|
|
30
|
+
name: 'login-otp',
|
|
31
|
+
referencedGeneratorTemplates: { otpConstants: {} },
|
|
32
|
+
source: {
|
|
33
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/login-otp.tsx'),
|
|
34
|
+
},
|
|
35
|
+
variables: {},
|
|
36
|
+
});
|
|
5
37
|
const constants = createTsTemplateFile({
|
|
6
38
|
fileOptions: { kind: 'singleton' },
|
|
7
39
|
group: 'main',
|
|
@@ -46,27 +78,7 @@ const login = createTsTemplateFile({
|
|
|
46
78
|
source: {
|
|
47
79
|
path: path.join(import.meta.dirname, '../templates/routes/auth_/login.tsx'),
|
|
48
80
|
},
|
|
49
|
-
variables: {},
|
|
50
|
-
});
|
|
51
|
-
const register = createTsTemplateFile({
|
|
52
|
-
fileOptions: { kind: 'singleton' },
|
|
53
|
-
group: 'main',
|
|
54
|
-
importMapProviders: {
|
|
55
|
-
apolloErrorImports: apolloErrorImportsProvider,
|
|
56
|
-
graphqlImports: graphqlImportsProvider,
|
|
57
|
-
reactComponentsImports: reactComponentsImportsProvider,
|
|
58
|
-
reactErrorImports: reactErrorImportsProvider,
|
|
59
|
-
reactSessionImports: reactSessionImportsProvider,
|
|
60
|
-
},
|
|
61
|
-
name: 'register',
|
|
62
|
-
source: {
|
|
63
|
-
path: path.join(import.meta.dirname, '../templates/routes/auth_/register.tsx'),
|
|
64
|
-
},
|
|
65
|
-
variables: {
|
|
66
|
-
TPL_NAME_FORM_CONTROL: {},
|
|
67
|
-
TPL_REGISTER_INPUT: {},
|
|
68
|
-
TPL_REGISTER_SCHEMA: {},
|
|
69
|
-
},
|
|
81
|
+
variables: { TPL_OTP_LOGIN_LINK: {}, TPL_REGISTER_LINK: {} },
|
|
70
82
|
});
|
|
71
83
|
const resetPassword = createTsTemplateFile({
|
|
72
84
|
fileOptions: { kind: 'singleton' },
|
|
@@ -98,10 +110,37 @@ export const mainGroup = {
|
|
|
98
110
|
constants,
|
|
99
111
|
forgotPassword,
|
|
100
112
|
login,
|
|
101
|
-
register,
|
|
102
113
|
resetPassword,
|
|
103
114
|
route,
|
|
104
115
|
};
|
|
116
|
+
const otpConstants = createTsTemplateFile({
|
|
117
|
+
fileOptions: { kind: 'singleton' },
|
|
118
|
+
importMapProviders: {},
|
|
119
|
+
name: 'otp-constants',
|
|
120
|
+
source: {
|
|
121
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/-otp-constants.ts'),
|
|
122
|
+
},
|
|
123
|
+
variables: {},
|
|
124
|
+
});
|
|
125
|
+
const register = createTsTemplateFile({
|
|
126
|
+
fileOptions: { kind: 'singleton' },
|
|
127
|
+
importMapProviders: {
|
|
128
|
+
apolloErrorImports: apolloErrorImportsProvider,
|
|
129
|
+
graphqlImports: graphqlImportsProvider,
|
|
130
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
131
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
132
|
+
reactSessionImports: reactSessionImportsProvider,
|
|
133
|
+
},
|
|
134
|
+
name: 'register',
|
|
135
|
+
source: {
|
|
136
|
+
path: path.join(import.meta.dirname, '../templates/routes/auth_/register.tsx'),
|
|
137
|
+
},
|
|
138
|
+
variables: {
|
|
139
|
+
TPL_NAME_FORM_CONTROL: {},
|
|
140
|
+
TPL_REGISTER_INPUT: {},
|
|
141
|
+
TPL_REGISTER_SCHEMA: {},
|
|
142
|
+
},
|
|
143
|
+
});
|
|
105
144
|
const verifyEmail = createTsTemplateFile({
|
|
106
145
|
fileOptions: { kind: 'singleton' },
|
|
107
146
|
importMapProviders: {
|
|
@@ -116,5 +155,12 @@ const verifyEmail = createTsTemplateFile({
|
|
|
116
155
|
},
|
|
117
156
|
variables: {},
|
|
118
157
|
});
|
|
119
|
-
export const AUTH_CORE_AUTH_ROUTES_TEMPLATES = {
|
|
158
|
+
export const AUTH_CORE_AUTH_ROUTES_TEMPLATES = {
|
|
159
|
+
acceptInvite,
|
|
160
|
+
loginOtp,
|
|
161
|
+
mainGroup,
|
|
162
|
+
otpConstants,
|
|
163
|
+
register,
|
|
164
|
+
verifyEmail,
|
|
165
|
+
};
|
|
120
166
|
//# sourceMappingURL=typed-templates.js.map
|
package/dist/local-auth/core/generators/auth-routes/templates/routes/auth_/-otp-constants.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
3
|
+
*/
|
|
4
|
+
export declare const EMAIL_OTP_LENGTH = 6;
|
|
5
|
+
/**
|
|
6
|
+
* Seconds to wait before another sign-in code can be requested
|
|
7
|
+
*/
|
|
8
|
+
export declare const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
9
|
+
//# sourceMappingURL=-otp-constants.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/**
|
|
3
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
4
|
+
*/
|
|
5
|
+
export const EMAIL_OTP_LENGTH = 6;
|
|
6
|
+
/**
|
|
7
|
+
* Seconds to wait before another sign-in code can be requested
|
|
8
|
+
*/
|
|
9
|
+
export const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
10
|
+
//# sourceMappingURL=-otp-constants.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Number of digits in an emailed sign-in code (matches backend validation)
|
|
5
|
+
*/
|
|
6
|
+
export const EMAIL_OTP_LENGTH = 6;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Seconds to wait before another sign-in code can be requested
|
|
10
|
+
*/
|
|
11
|
+
export const EMAIL_OTP_RESEND_COOLDOWN_SEC = 60;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Route: import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, never, never, never, never, never, z.ZodObject<{
|
|
3
|
+
token: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, ({ search: { token }, context: { userId } }: import("@tanstack/react-router").BeforeLoadContextOptions<import("@tanstack/react-router").Register, never, z.ZodObject<{
|
|
5
|
+
token: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, never, unknown, undefined>) => void, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
7
|
+
//# sourceMappingURL=accept-invite.d.ts.map
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH } from '$constants';
|
|
4
|
+
import { getApolloErrorCode } from '%apolloErrorImports';
|
|
5
|
+
import { graphql } from '%graphqlImports';
|
|
6
|
+
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, InputFieldController, } from '%reactComponentsImports';
|
|
7
|
+
import { logAndFormatError, logError } from '%reactErrorImports';
|
|
8
|
+
import { userSessionClient } from '%reactSessionImports';
|
|
9
|
+
import { useMutation } from '@apollo/client/react';
|
|
10
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
11
|
+
import { createFileRoute, Link, redirect, useNavigate, } from '@tanstack/react-router';
|
|
12
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
13
|
+
import { useForm } from 'react-hook-form';
|
|
14
|
+
import { toast } from 'sonner';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
export const Route = createFileRoute('/auth_/accept-invite')({
|
|
17
|
+
validateSearch: z.object({
|
|
18
|
+
token: z.string().optional(),
|
|
19
|
+
}),
|
|
20
|
+
component: AcceptInvitePage,
|
|
21
|
+
beforeLoad: ({ search: { token }, context: { userId } }) => {
|
|
22
|
+
if (userId) {
|
|
23
|
+
throw redirect({ to: '/' });
|
|
24
|
+
}
|
|
25
|
+
if (!token) {
|
|
26
|
+
throw redirect({ to: '/auth/login' });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const formSchema = z
|
|
31
|
+
.object({
|
|
32
|
+
newPassword: z
|
|
33
|
+
.string()
|
|
34
|
+
.min(PASSWORD_MIN_LENGTH, `Password must be at least ${PASSWORD_MIN_LENGTH} characters`)
|
|
35
|
+
.max(PASSWORD_MAX_LENGTH),
|
|
36
|
+
confirmPassword: z.string(),
|
|
37
|
+
})
|
|
38
|
+
.refine((data) => data.newPassword === data.confirmPassword, {
|
|
39
|
+
message: 'Passwords do not match',
|
|
40
|
+
path: ['confirmPassword'],
|
|
41
|
+
});
|
|
42
|
+
const validateInviteTokenMutation = graphql(`
|
|
43
|
+
mutation ValidateInviteToken($input: ValidateInviteTokenInput!) {
|
|
44
|
+
validateInviteToken(input: $input) {
|
|
45
|
+
email
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`);
|
|
49
|
+
const acceptInviteMutation = graphql(`
|
|
50
|
+
mutation AcceptInvite($input: AcceptInviteInput!) {
|
|
51
|
+
acceptInvite(input: $input) {
|
|
52
|
+
session {
|
|
53
|
+
userId
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`);
|
|
58
|
+
function AcceptInvitePage() {
|
|
59
|
+
const { token } = Route.useSearch();
|
|
60
|
+
const navigate = useNavigate();
|
|
61
|
+
const [tokenValid, setTokenValid] = useState(null);
|
|
62
|
+
const [email, setEmail] = useState(null);
|
|
63
|
+
const [validationError, setValidationError] = useState(null);
|
|
64
|
+
const [validateInviteToken] = useMutation(validateInviteTokenMutation);
|
|
65
|
+
const [acceptInvite, { loading }] = useMutation(acceptInviteMutation);
|
|
66
|
+
const { control, handleSubmit } = useForm({
|
|
67
|
+
resolver: zodResolver(formSchema),
|
|
68
|
+
reValidateMode: 'onBlur',
|
|
69
|
+
});
|
|
70
|
+
const runTokenValidation = useCallback(() => {
|
|
71
|
+
if (!token)
|
|
72
|
+
return;
|
|
73
|
+
setTokenValid(null);
|
|
74
|
+
setValidationError(null);
|
|
75
|
+
validateInviteToken({
|
|
76
|
+
variables: { input: { token } },
|
|
77
|
+
})
|
|
78
|
+
.then(({ data }) => {
|
|
79
|
+
setTokenValid(true);
|
|
80
|
+
setEmail(data?.validateInviteToken.email ?? null);
|
|
81
|
+
})
|
|
82
|
+
.catch((err) => {
|
|
83
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token']);
|
|
84
|
+
switch (errorCode) {
|
|
85
|
+
case 'invalid-token': {
|
|
86
|
+
setTokenValid(false);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
case null: {
|
|
90
|
+
setValidationError(logAndFormatError(err, 'Sorry, we could not validate your invite link.'));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}, [token, validateInviteToken]);
|
|
95
|
+
// Validate token on mount
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
runTokenValidation();
|
|
98
|
+
}, [runTokenValidation]);
|
|
99
|
+
const onSubmit = (data) => {
|
|
100
|
+
if (!token)
|
|
101
|
+
return;
|
|
102
|
+
acceptInvite({
|
|
103
|
+
variables: {
|
|
104
|
+
input: {
|
|
105
|
+
token,
|
|
106
|
+
newPassword: data.newPassword,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
.then(({ data }) => {
|
|
111
|
+
if (!data) {
|
|
112
|
+
throw new Error('No data returned from accept invite mutation');
|
|
113
|
+
}
|
|
114
|
+
const { userId } = data.acceptInvite.session;
|
|
115
|
+
userSessionClient.signIn(userId);
|
|
116
|
+
navigate({ to: '/', replace: true }).catch(logError);
|
|
117
|
+
})
|
|
118
|
+
.catch((err) => {
|
|
119
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token']);
|
|
120
|
+
switch (errorCode) {
|
|
121
|
+
case 'invalid-token': {
|
|
122
|
+
setTokenValid(false);
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case null: {
|
|
126
|
+
toast.error(logAndFormatError(err, 'Sorry, we could not accept your invite.'));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
// Loading state
|
|
132
|
+
if (tokenValid === null && !validationError) {
|
|
133
|
+
return (_jsx(Card, { children: _jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Validating..." }), _jsx(CardDescription, { children: "Please wait while we verify your invite link." })] }) }));
|
|
134
|
+
}
|
|
135
|
+
// Validation error state (transient failures, not invalid token)
|
|
136
|
+
if (validationError) {
|
|
137
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Something Went Wrong" }), _jsx(CardDescription, { children: validationError })] }), _jsx(CardContent, { children: _jsx(Button, { variant: "secondary", className: "w-full", onClick: runTokenValidation, children: "Try Again" }) })] }));
|
|
138
|
+
}
|
|
139
|
+
// Invalid token state
|
|
140
|
+
if (!tokenValid) {
|
|
141
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Invalid or Expired Invite" }), _jsx(CardDescription, { children: "This invite link is invalid or has expired. Please ask an admin to send you a new one." })] }), _jsx(CardContent, { children: _jsx(Link, { to: "/auth/login", children: _jsx(Button, { variant: "secondary", className: "w-full", children: "Back to Login" }) }) })] }));
|
|
142
|
+
}
|
|
143
|
+
// Set password form
|
|
144
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Set your password" }), _jsx(CardDescription, { children: email
|
|
145
|
+
? `Choose a password to finish setting up ${email}.`
|
|
146
|
+
: 'Choose a password to finish setting up your account.' })] }), _jsx(CardContent, { children: _jsx("form", { onSubmit: handleSubmit(onSubmit), children: _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(InputFieldController, { control: control, name: "newPassword", label: "Password", type: "password", autoComplete: "new-password", placeholder: "Enter a password" }), _jsx(InputFieldController, { control: control, name: "confirmPassword", label: "Confirm Password", type: "password", autoComplete: "new-password", placeholder: "Confirm your password" }), _jsx(Button, { type: "submit", className: "w-full", disabled: loading, children: "Get Started" })] }) }) })] }));
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=accept-invite.js.map
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import { PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH } from '$constants';
|
|
4
|
+
import { getApolloErrorCode } from '%apolloErrorImports';
|
|
5
|
+
import { graphql } from '%graphqlImports';
|
|
6
|
+
import {
|
|
7
|
+
Button,
|
|
8
|
+
Card,
|
|
9
|
+
CardContent,
|
|
10
|
+
CardDescription,
|
|
11
|
+
CardHeader,
|
|
12
|
+
CardTitle,
|
|
13
|
+
InputFieldController,
|
|
14
|
+
} from '%reactComponentsImports';
|
|
15
|
+
import { logAndFormatError, logError } from '%reactErrorImports';
|
|
16
|
+
import { userSessionClient } from '%reactSessionImports';
|
|
17
|
+
import { useMutation } from '@apollo/client/react';
|
|
18
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
19
|
+
import {
|
|
20
|
+
createFileRoute,
|
|
21
|
+
Link,
|
|
22
|
+
redirect,
|
|
23
|
+
useNavigate,
|
|
24
|
+
} from '@tanstack/react-router';
|
|
25
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
26
|
+
import { useForm } from 'react-hook-form';
|
|
27
|
+
import { toast } from 'sonner';
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
|
|
30
|
+
export const Route = createFileRoute('/auth_/accept-invite')({
|
|
31
|
+
validateSearch: z.object({
|
|
32
|
+
token: z.string().optional(),
|
|
33
|
+
}),
|
|
34
|
+
component: AcceptInvitePage,
|
|
35
|
+
beforeLoad: ({ search: { token }, context: { userId } }) => {
|
|
36
|
+
if (userId) {
|
|
37
|
+
throw redirect({ to: '/' });
|
|
38
|
+
}
|
|
39
|
+
if (!token) {
|
|
40
|
+
throw redirect({ to: '/auth/login' });
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const formSchema = z
|
|
46
|
+
.object({
|
|
47
|
+
newPassword: z
|
|
48
|
+
.string()
|
|
49
|
+
.min(
|
|
50
|
+
PASSWORD_MIN_LENGTH,
|
|
51
|
+
`Password must be at least ${PASSWORD_MIN_LENGTH} characters`,
|
|
52
|
+
)
|
|
53
|
+
.max(PASSWORD_MAX_LENGTH),
|
|
54
|
+
confirmPassword: z.string(),
|
|
55
|
+
})
|
|
56
|
+
.refine((data) => data.newPassword === data.confirmPassword, {
|
|
57
|
+
message: 'Passwords do not match',
|
|
58
|
+
path: ['confirmPassword'],
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
type FormData = z.infer<typeof formSchema>;
|
|
62
|
+
|
|
63
|
+
const validateInviteTokenMutation = graphql(`
|
|
64
|
+
mutation ValidateInviteToken($input: ValidateInviteTokenInput!) {
|
|
65
|
+
validateInviteToken(input: $input) {
|
|
66
|
+
email
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
`);
|
|
70
|
+
|
|
71
|
+
const acceptInviteMutation = graphql(`
|
|
72
|
+
mutation AcceptInvite($input: AcceptInviteInput!) {
|
|
73
|
+
acceptInvite(input: $input) {
|
|
74
|
+
session {
|
|
75
|
+
userId
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
`);
|
|
80
|
+
|
|
81
|
+
function AcceptInvitePage(): React.JSX.Element {
|
|
82
|
+
const { token } = Route.useSearch();
|
|
83
|
+
const navigate = useNavigate();
|
|
84
|
+
const [tokenValid, setTokenValid] = useState<boolean | null>(null);
|
|
85
|
+
const [email, setEmail] = useState<string | null>(null);
|
|
86
|
+
const [validationError, setValidationError] = useState<string | null>(null);
|
|
87
|
+
|
|
88
|
+
const [validateInviteToken] = useMutation(validateInviteTokenMutation);
|
|
89
|
+
const [acceptInvite, { loading }] = useMutation(acceptInviteMutation);
|
|
90
|
+
|
|
91
|
+
const { control, handleSubmit } = useForm<FormData>({
|
|
92
|
+
resolver: zodResolver(formSchema),
|
|
93
|
+
reValidateMode: 'onBlur',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const runTokenValidation = useCallback(() => {
|
|
97
|
+
if (!token) return;
|
|
98
|
+
|
|
99
|
+
setTokenValid(null);
|
|
100
|
+
setValidationError(null);
|
|
101
|
+
|
|
102
|
+
validateInviteToken({
|
|
103
|
+
variables: { input: { token } },
|
|
104
|
+
})
|
|
105
|
+
.then(({ data }) => {
|
|
106
|
+
setTokenValid(true);
|
|
107
|
+
setEmail(data?.validateInviteToken.email ?? null);
|
|
108
|
+
})
|
|
109
|
+
.catch((err: unknown) => {
|
|
110
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token'] as const);
|
|
111
|
+
switch (errorCode) {
|
|
112
|
+
case 'invalid-token': {
|
|
113
|
+
setTokenValid(false);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
case null: {
|
|
117
|
+
setValidationError(
|
|
118
|
+
logAndFormatError(
|
|
119
|
+
err,
|
|
120
|
+
'Sorry, we could not validate your invite link.',
|
|
121
|
+
),
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}, [token, validateInviteToken]);
|
|
127
|
+
|
|
128
|
+
// Validate token on mount
|
|
129
|
+
useEffect(() => {
|
|
130
|
+
runTokenValidation();
|
|
131
|
+
}, [runTokenValidation]);
|
|
132
|
+
|
|
133
|
+
const onSubmit = (data: FormData): void => {
|
|
134
|
+
if (!token) return;
|
|
135
|
+
|
|
136
|
+
acceptInvite({
|
|
137
|
+
variables: {
|
|
138
|
+
input: {
|
|
139
|
+
token,
|
|
140
|
+
newPassword: data.newPassword,
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
.then(({ data }) => {
|
|
145
|
+
if (!data) {
|
|
146
|
+
throw new Error('No data returned from accept invite mutation');
|
|
147
|
+
}
|
|
148
|
+
const { userId } = data.acceptInvite.session;
|
|
149
|
+
userSessionClient.signIn(userId);
|
|
150
|
+
|
|
151
|
+
navigate({ to: '/', replace: true }).catch(logError);
|
|
152
|
+
})
|
|
153
|
+
.catch((err: unknown) => {
|
|
154
|
+
const errorCode = getApolloErrorCode(err, ['invalid-token'] as const);
|
|
155
|
+
switch (errorCode) {
|
|
156
|
+
case 'invalid-token': {
|
|
157
|
+
setTokenValid(false);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
case null: {
|
|
161
|
+
toast.error(
|
|
162
|
+
logAndFormatError(err, 'Sorry, we could not accept your invite.'),
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Loading state
|
|
170
|
+
if (tokenValid === null && !validationError) {
|
|
171
|
+
return (
|
|
172
|
+
<Card>
|
|
173
|
+
<CardHeader>
|
|
174
|
+
<CardTitle>Validating...</CardTitle>
|
|
175
|
+
<CardDescription>
|
|
176
|
+
Please wait while we verify your invite link.
|
|
177
|
+
</CardDescription>
|
|
178
|
+
</CardHeader>
|
|
179
|
+
</Card>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// Validation error state (transient failures, not invalid token)
|
|
184
|
+
if (validationError) {
|
|
185
|
+
return (
|
|
186
|
+
<Card>
|
|
187
|
+
<CardHeader>
|
|
188
|
+
<CardTitle>Something Went Wrong</CardTitle>
|
|
189
|
+
<CardDescription>{validationError}</CardDescription>
|
|
190
|
+
</CardHeader>
|
|
191
|
+
<CardContent>
|
|
192
|
+
<Button
|
|
193
|
+
variant="secondary"
|
|
194
|
+
className="w-full"
|
|
195
|
+
onClick={runTokenValidation}
|
|
196
|
+
>
|
|
197
|
+
Try Again
|
|
198
|
+
</Button>
|
|
199
|
+
</CardContent>
|
|
200
|
+
</Card>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Invalid token state
|
|
205
|
+
if (!tokenValid) {
|
|
206
|
+
return (
|
|
207
|
+
<Card>
|
|
208
|
+
<CardHeader>
|
|
209
|
+
<CardTitle>Invalid or Expired Invite</CardTitle>
|
|
210
|
+
<CardDescription>
|
|
211
|
+
This invite link is invalid or has expired. Please ask an admin to
|
|
212
|
+
send you a new one.
|
|
213
|
+
</CardDescription>
|
|
214
|
+
</CardHeader>
|
|
215
|
+
<CardContent>
|
|
216
|
+
<Link to="/auth/login">
|
|
217
|
+
<Button variant="secondary" className="w-full">
|
|
218
|
+
Back to Login
|
|
219
|
+
</Button>
|
|
220
|
+
</Link>
|
|
221
|
+
</CardContent>
|
|
222
|
+
</Card>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Set password form
|
|
227
|
+
return (
|
|
228
|
+
<Card>
|
|
229
|
+
<CardHeader>
|
|
230
|
+
<CardTitle>Set your password</CardTitle>
|
|
231
|
+
<CardDescription>
|
|
232
|
+
{email
|
|
233
|
+
? `Choose a password to finish setting up ${email}.`
|
|
234
|
+
: 'Choose a password to finish setting up your account.'}
|
|
235
|
+
</CardDescription>
|
|
236
|
+
</CardHeader>
|
|
237
|
+
<CardContent>
|
|
238
|
+
<form onSubmit={handleSubmit(onSubmit)}>
|
|
239
|
+
<div className="flex flex-col gap-6">
|
|
240
|
+
<InputFieldController
|
|
241
|
+
control={control}
|
|
242
|
+
name="newPassword"
|
|
243
|
+
label="Password"
|
|
244
|
+
type="password"
|
|
245
|
+
autoComplete="new-password"
|
|
246
|
+
placeholder="Enter a password"
|
|
247
|
+
/>
|
|
248
|
+
<InputFieldController
|
|
249
|
+
control={control}
|
|
250
|
+
name="confirmPassword"
|
|
251
|
+
label="Confirm Password"
|
|
252
|
+
type="password"
|
|
253
|
+
autoComplete="new-password"
|
|
254
|
+
placeholder="Confirm your password"
|
|
255
|
+
/>
|
|
256
|
+
<Button type="submit" className="w-full" disabled={loading}>
|
|
257
|
+
Get Started
|
|
258
|
+
</Button>
|
|
259
|
+
</div>
|
|
260
|
+
</form>
|
|
261
|
+
</CardContent>
|
|
262
|
+
</Card>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const Route: import("@tanstack/router-core").Route<import("@tanstack/react-router").Register, never, never, never, never, never, z.ZodObject<{
|
|
3
|
+
return_to: z.ZodOptional<z.ZodString>;
|
|
4
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, ({ search: { return_to }, context: { userId } }: import("@tanstack/react-router").BeforeLoadContextOptions<import("@tanstack/react-router").Register, never, z.ZodObject<{
|
|
5
|
+
return_to: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, z.core.$strip>, import("@tanstack/react-router").ResolveParams<never>, import("@tanstack/react-router").AnyContext, import("@tanstack/react-router").AnyContext, never, unknown, undefined>) => void, {}, undefined, unknown, unknown, unknown, unknown, undefined>;
|
|
7
|
+
//# sourceMappingURL=login-otp.d.ts.map
|