@baseplate-dev/plugin-auth 0.6.17 → 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 +20 -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-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 +4 -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 +20 -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 +3 -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 +17 -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-ChkXxpXe.js → _virtual_mf-localSharedImportMap___mfe_internal__plugin_mf_2_auth__mf_owner__1-CKKmnLep.js} +42 -34
- package/dist/web/assets/{dist-DY7ZXvq4.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} +16717 -373
- 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-37vlYRxk.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_mf_1_web__loadShare__.js-D3Nvasea.js} +90 -38
- 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-DRSNXPPo.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} +1645 -921
- package/dist/web/assets/{_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare___mf_0_tanstack_mf_1_react_mf_2_router__loadShare__.js-DfiQqvVC.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} +212 -57
- package/dist/web/assets/auth-CsHp2bQi.js +1 -0
- package/dist/web/assets/common-BGTuTgx7.js +43 -0
- package/dist/web/assets/common-C8_sC5pp.js +70 -0
- package/dist/web/assets/{common-ByxS61u8.js → common-Co5lW_TK.js} +10 -10
- package/dist/web/assets/{common-iHaemino.js → common-CoLuMS7U.js} +6 -6
- package/dist/web/assets/common-Dueu_1NG.js +36 -0
- package/dist/web/assets/{common-TDf_PrjX.js → common-N3skPbzk.js} +10 -10
- package/dist/web/assets/{dist-CrLSslv6.js → dist-DQd1TAJX.js} +273 -132
- package/dist/web/assets/{get-auth-plugin-definition-kDCtXq_6.js → get-auth-plugin-definition-DyokUVjX.js} +3 -3
- package/dist/web/assets/{hostInit-Cruek6c6.js → hostInit-BCYmw0H5.js} +32 -5
- package/dist/web/assets/{mf-entry-bootstrap-0-dfed0275.js → mf-entry-bootstrap-0-3ede9334.js} +2 -1
- package/dist/web/assets/{mf-entry-bootstrap-1-5275674a.js → mf-entry-bootstrap-1-3da85eea.js} +3 -2
- package/dist/web/assets/{mf-entry-bootstrap-2-39fb9255.js → mf-entry-bootstrap-2-32e24e11.js} +3 -2
- package/dist/web/assets/{mf-entry-bootstrap-3-49e64336.js → mf-entry-bootstrap-3-a3cfea9d.js} +3 -2
- package/dist/web/assets/{models-DSvs_3bA.js → models-BcPOQC5p.js} +4 -5
- package/dist/web/assets/{models-BZmCbizK.js → models-BcUgOGGn.js} +11 -6
- package/dist/web/assets/{plugin-definition-CYj29S3q.js → plugin-definition-D1EImXIf.js} +9 -10
- package/dist/web/assets/plugin-definition-lw-gB4hU.js +10 -0
- package/dist/web/assets/{styles-yjbHBTlw.js → styles-EOyEbGA4.js} +9 -10
- package/dist/web/assets/{virtualExposes-CbPBmicF.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-B6BXIeF1.js → virtual_mf-exposes___mfe_internal__plugin-auth__remoteEntry_js-DZfE3QCR.js} +13 -13
- package/dist/web/assets/{web-VqBA3jxZ.js → web-CBVepebK.js} +22 -22
- package/dist/web/assets/{web-D0MSKfyv.js → web-Dgb85jhs.js} +47 -47
- package/dist/web/assets/{web-CXAHKjIY.js → web-EDeSquSP.js} +28 -28
- package/dist/web/assets/{web-1eTcxMhf.js → web-PqAcfBSy.js} +9 -9
- package/dist/web/assets/{web-CDAKPPK9.js → web-RhChfBw_.js} +21 -21
- package/dist/web/assets/web-kaD9AzNS.js +59 -0
- package/dist/web/assets/web-xJ-GnSkC.js +148 -0
- package/dist/web/index.html +5 -5
- package/dist/web/remoteEntry.js +1 -1
- package/package.json +14 -14
- 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-CO5Pvo0y.js +0 -384
- package/dist/web/assets/_virtual_mf___mfe_internal__plugin_mf_2_auth__loadShare__zod__loadShare__.js-BEZ7A-cz.js +0 -13566
- package/dist/web/assets/auth-BxAE0rgh.js +0 -1
- package/dist/web/assets/common-CKl_XlvH.js +0 -37
- package/dist/web/assets/common-UpVCKZeW.js +0 -41
- package/dist/web/assets/common-crSwCD36.js +0 -37
- package/dist/web/assets/model-utils-C0WDb_Ec.js +0 -1599
- package/dist/web/assets/plugin-definition-DOMmPL2Z.js +0 -11
- package/dist/web/assets/virtual_mf-REMOTE_ENTRY_ID___mfe_internal__plugin-auth__remoteEntry_js-XM6iYVxf.js +0 -259
- package/dist/web/assets/virtual_mf-exposes-ssr___mfe_internal__plugin-auth__remoteEntry_js-DGjg7Brm.js +0 -129
- package/dist/web/assets/web-DbeAaDTV.js +0 -118
- package/dist/web/assets/web-miDovYk_.js +0 -46
- package/dist/web/remoteEntry.ssr.js +0 -43
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
import { EMAIL_OTP_LENGTH, EMAIL_OTP_RESEND_COOLDOWN_SEC } from '$otpConstants';
|
|
4
|
+
import { getApolloErrorCode } from '%apolloErrorImports';
|
|
5
|
+
import { graphql } from '%graphqlImports';
|
|
6
|
+
import { Button, Card, CardContent, CardDescription, CardHeader, CardTitle, InputFieldController, InputOtpFieldController, } 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 { 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_/login-otp')({
|
|
17
|
+
validateSearch: z.object({
|
|
18
|
+
return_to: z
|
|
19
|
+
.string()
|
|
20
|
+
.refine((v) => v.startsWith('/') && !v.startsWith('//'))
|
|
21
|
+
.optional(),
|
|
22
|
+
}),
|
|
23
|
+
component: LoginOtpPage,
|
|
24
|
+
beforeLoad: ({ search: { return_to }, context: { userId } }) => {
|
|
25
|
+
if (userId) {
|
|
26
|
+
throw redirect({ to: return_to ?? '/' });
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const emailSchema = z.object({
|
|
31
|
+
email: z
|
|
32
|
+
.email('Please enter a valid email address')
|
|
33
|
+
.transform((value) => value.toLowerCase()),
|
|
34
|
+
});
|
|
35
|
+
const codeSchema = z.object({
|
|
36
|
+
code: z
|
|
37
|
+
.string()
|
|
38
|
+
.length(EMAIL_OTP_LENGTH, `Enter the ${EMAIL_OTP_LENGTH}-digit code`),
|
|
39
|
+
name: z.string().max(100).optional(),
|
|
40
|
+
});
|
|
41
|
+
const requestEmailOtpMutation = graphql(`
|
|
42
|
+
mutation RequestEmailOtp($input: RequestEmailOtpInput!) {
|
|
43
|
+
requestEmailOtp(input: $input) {
|
|
44
|
+
success
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
`);
|
|
48
|
+
const signInWithEmailOtpMutation = graphql(`
|
|
49
|
+
mutation SignInWithEmailOtp($input: SignInWithEmailOtpInput!) {
|
|
50
|
+
signInWithEmailOtp(input: $input) {
|
|
51
|
+
session {
|
|
52
|
+
userId
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
`);
|
|
57
|
+
function LoginOtpPage() {
|
|
58
|
+
const [sentToEmail, setSentToEmail] = useState();
|
|
59
|
+
// Set once the server reports the code is valid but the address is new and
|
|
60
|
+
// needs a name. Revealing the field any earlier would leak whether an
|
|
61
|
+
// account exists.
|
|
62
|
+
const [needsName, setNeedsName] = useState(false);
|
|
63
|
+
const [resendCooldown, setResendCooldown] = useState(0);
|
|
64
|
+
const navigate = useNavigate();
|
|
65
|
+
const { return_to } = Route.useSearch();
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (resendCooldown <= 0)
|
|
68
|
+
return;
|
|
69
|
+
const timer = setTimeout(() => {
|
|
70
|
+
setResendCooldown((seconds) => seconds - 1);
|
|
71
|
+
}, 1000);
|
|
72
|
+
return () => {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
};
|
|
75
|
+
}, [resendCooldown]);
|
|
76
|
+
const emailForm = useForm({
|
|
77
|
+
resolver: zodResolver(emailSchema),
|
|
78
|
+
reValidateMode: 'onBlur',
|
|
79
|
+
});
|
|
80
|
+
const codeForm = useForm({
|
|
81
|
+
resolver: zodResolver(codeSchema),
|
|
82
|
+
reValidateMode: 'onBlur',
|
|
83
|
+
});
|
|
84
|
+
const [requestEmailOtp, { loading: isRequesting }] = useMutation(requestEmailOtpMutation);
|
|
85
|
+
const [signInWithEmailOtp, { loading: isVerifying }] = useMutation(signInWithEmailOtpMutation);
|
|
86
|
+
const onRequestCode = ({ email }) => {
|
|
87
|
+
requestEmailOtp({ variables: { input: { email } } })
|
|
88
|
+
.then(() => {
|
|
89
|
+
setSentToEmail(email);
|
|
90
|
+
setResendCooldown(EMAIL_OTP_RESEND_COOLDOWN_SEC);
|
|
91
|
+
// Only the code is cleared: a resend keeps any name already collected
|
|
92
|
+
// so the user does not have to type it a second time.
|
|
93
|
+
codeForm.resetField('code');
|
|
94
|
+
})
|
|
95
|
+
.catch((err) => {
|
|
96
|
+
const errorCode = getApolloErrorCode(err, ['too-many-requests']);
|
|
97
|
+
if (errorCode === 'too-many-requests') {
|
|
98
|
+
const message = 'Too many sign-in code requests. Please try again later.';
|
|
99
|
+
// The email form is unmounted once a code has been sent, so a
|
|
100
|
+
// rate-limited resend has nowhere to show a field error.
|
|
101
|
+
if (sentToEmail) {
|
|
102
|
+
toast.error(message);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
emailForm.setError('email', { message });
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
toast.error(logAndFormatError(err, 'Sorry, we could not send you a code.'));
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
const onVerifyCode = ({ code, name }) => {
|
|
113
|
+
if (!sentToEmail)
|
|
114
|
+
return;
|
|
115
|
+
const trimmedName = name?.trim();
|
|
116
|
+
// Send a blank name as absent so the server answers with `name-required`
|
|
117
|
+
// rather than a validation error.
|
|
118
|
+
const nameInput = trimmedName ? trimmedName : undefined;
|
|
119
|
+
if (needsName && !nameInput) {
|
|
120
|
+
codeForm.setError('name', { message: 'Please enter your name' }, { shouldFocus: true });
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
signInWithEmailOtp({
|
|
124
|
+
variables: { input: { email: sentToEmail, code, name: nameInput } },
|
|
125
|
+
})
|
|
126
|
+
.then(({ data }) => {
|
|
127
|
+
if (!data) {
|
|
128
|
+
throw new Error('No data returned from sign-in mutation');
|
|
129
|
+
}
|
|
130
|
+
const { userId } = data.signInWithEmailOtp.session;
|
|
131
|
+
userSessionClient.signIn(userId);
|
|
132
|
+
navigate({ to: return_to ?? '/', replace: true }).catch(logError);
|
|
133
|
+
})
|
|
134
|
+
.catch((err) => {
|
|
135
|
+
const errorCode = getApolloErrorCode(err, [
|
|
136
|
+
'invalid-code',
|
|
137
|
+
'name-required',
|
|
138
|
+
'too-many-requests',
|
|
139
|
+
'verification-context-missing',
|
|
140
|
+
]);
|
|
141
|
+
switch (errorCode) {
|
|
142
|
+
case 'invalid-code': {
|
|
143
|
+
codeForm.setError('code', { message: 'That code is incorrect or has expired' }, { shouldFocus: true });
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
case 'verification-context-missing': {
|
|
147
|
+
codeForm.setError('code', {
|
|
148
|
+
message: 'Codes can only be used in the browser that requested them. Request a new one to continue.',
|
|
149
|
+
});
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case 'name-required': {
|
|
153
|
+
// The code is still valid — collect a name and submit it again.
|
|
154
|
+
setNeedsName(true);
|
|
155
|
+
codeForm.setError('name', { message: 'Please enter your name' }, { shouldFocus: true });
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case 'too-many-requests': {
|
|
159
|
+
codeForm.setError('code', {
|
|
160
|
+
message: 'Too many attempts. Please try again later.',
|
|
161
|
+
});
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
case null: {
|
|
165
|
+
toast.error(logAndFormatError(err, 'Sorry, we could not sign you in.'));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsxs(CardTitle, { children: [!sentToEmail && 'Sign in with a code', sentToEmail &&
|
|
171
|
+
(needsName ? 'Finish creating your account' : 'Enter your code')] }), _jsxs(CardDescription, { children: [!sentToEmail &&
|
|
172
|
+
`We'll email you a code so you can sign in without a password.`, sentToEmail &&
|
|
173
|
+
(needsName
|
|
174
|
+
? 'Your code checked out — tell us your name to finish setting up your account.'
|
|
175
|
+
: `We sent a ${EMAIL_OTP_LENGTH}-digit code to ${sentToEmail}.`)] })] }), _jsx(CardContent, { children: sentToEmail ? (_jsxs("form", { onSubmit: codeForm.handleSubmit(onVerifyCode), children: [_jsxs("div", { className: "flex flex-col items-center gap-4", children: [_jsx(InputOtpFieldController, { control: codeForm.control, name: "code", length: EMAIL_OTP_LENGTH }), needsName && (_jsx(InputFieldController, { control: codeForm.control, name: "name", label: "Your name", autoComplete: "name", className: "w-full" })), _jsx(Button, { type: "submit", className: "w-full", disabled: isVerifying, children: needsName ? 'Create account' : 'Sign in' })] }), _jsxs("div", { className: "mt-4 flex flex-col gap-4 text-center text-sm", children: [_jsx("button", { type: "button", className: "text-muted-foreground underline-offset-4 hover:underline disabled:no-underline disabled:opacity-70", disabled: resendCooldown > 0 || isRequesting, onClick: () => {
|
|
176
|
+
onRequestCode({ email: sentToEmail });
|
|
177
|
+
}, children: resendCooldown > 0
|
|
178
|
+
? `Resend code in ${resendCooldown}s`
|
|
179
|
+
: 'Resend code' }), _jsx("button", { type: "button", className: "text-muted-foreground underline-offset-4 hover:underline", onClick: () => {
|
|
180
|
+
setSentToEmail(undefined);
|
|
181
|
+
setNeedsName(false);
|
|
182
|
+
}, children: "Use a different email" })] })] })) : (_jsxs("form", { onSubmit: emailForm.handleSubmit(onRequestCode), children: [_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(InputFieldController, { control: emailForm.control, name: "email", type: "email", autoComplete: "email", placeholder: "user@example.com" }), _jsx(Button, { type: "submit", className: "w-full", disabled: isRequesting, children: "Email me a code" })] }), _jsx("div", { className: "mt-4 flex flex-col gap-4 text-center text-sm", children: _jsx(Link, { to: "/auth/login", search: { return_to }, className: "text-muted-foreground underline-offset-4 hover:underline", children: "Sign in with a password instead" }) })] })) })] }));
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=login-otp.js.map
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import { EMAIL_OTP_LENGTH, EMAIL_OTP_RESEND_COOLDOWN_SEC } from '$otpConstants';
|
|
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
|
+
InputOtpFieldController,
|
|
15
|
+
} from '%reactComponentsImports';
|
|
16
|
+
import { logAndFormatError, logError } from '%reactErrorImports';
|
|
17
|
+
import { userSessionClient } from '%reactSessionImports';
|
|
18
|
+
import { useMutation } from '@apollo/client/react';
|
|
19
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
20
|
+
import {
|
|
21
|
+
createFileRoute,
|
|
22
|
+
Link,
|
|
23
|
+
redirect,
|
|
24
|
+
useNavigate,
|
|
25
|
+
} from '@tanstack/react-router';
|
|
26
|
+
import { useEffect, useState } from 'react';
|
|
27
|
+
import { useForm } from 'react-hook-form';
|
|
28
|
+
import { toast } from 'sonner';
|
|
29
|
+
import { z } from 'zod';
|
|
30
|
+
|
|
31
|
+
export const Route = createFileRoute('/auth_/login-otp')({
|
|
32
|
+
validateSearch: z.object({
|
|
33
|
+
return_to: z
|
|
34
|
+
.string()
|
|
35
|
+
.refine((v) => v.startsWith('/') && !v.startsWith('//'))
|
|
36
|
+
.optional(),
|
|
37
|
+
}),
|
|
38
|
+
component: LoginOtpPage,
|
|
39
|
+
beforeLoad: ({ search: { return_to }, context: { userId } }) => {
|
|
40
|
+
if (userId) {
|
|
41
|
+
throw redirect({ to: return_to ?? '/' });
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const emailSchema = z.object({
|
|
47
|
+
email: z
|
|
48
|
+
.email('Please enter a valid email address')
|
|
49
|
+
.transform((value) => value.toLowerCase()),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const codeSchema = z.object({
|
|
53
|
+
code: z
|
|
54
|
+
.string()
|
|
55
|
+
.length(EMAIL_OTP_LENGTH, `Enter the ${EMAIL_OTP_LENGTH}-digit code`),
|
|
56
|
+
name: z.string().max(100).optional(),
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
type EmailFormData = z.infer<typeof emailSchema>;
|
|
60
|
+
type CodeFormData = z.infer<typeof codeSchema>;
|
|
61
|
+
|
|
62
|
+
const requestEmailOtpMutation = graphql(`
|
|
63
|
+
mutation RequestEmailOtp($input: RequestEmailOtpInput!) {
|
|
64
|
+
requestEmailOtp(input: $input) {
|
|
65
|
+
success
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`);
|
|
69
|
+
|
|
70
|
+
const signInWithEmailOtpMutation = graphql(`
|
|
71
|
+
mutation SignInWithEmailOtp($input: SignInWithEmailOtpInput!) {
|
|
72
|
+
signInWithEmailOtp(input: $input) {
|
|
73
|
+
session {
|
|
74
|
+
userId
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`);
|
|
79
|
+
|
|
80
|
+
function LoginOtpPage(): React.JSX.Element {
|
|
81
|
+
const [sentToEmail, setSentToEmail] = useState<string | undefined>();
|
|
82
|
+
// Set once the server reports the code is valid but the address is new and
|
|
83
|
+
// needs a name. Revealing the field any earlier would leak whether an
|
|
84
|
+
// account exists.
|
|
85
|
+
const [needsName, setNeedsName] = useState(false);
|
|
86
|
+
const [resendCooldown, setResendCooldown] = useState(0);
|
|
87
|
+
const navigate = useNavigate();
|
|
88
|
+
const { return_to } = Route.useSearch();
|
|
89
|
+
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (resendCooldown <= 0) return;
|
|
92
|
+
const timer = setTimeout(() => {
|
|
93
|
+
setResendCooldown((seconds) => seconds - 1);
|
|
94
|
+
}, 1000);
|
|
95
|
+
return () => {
|
|
96
|
+
clearTimeout(timer);
|
|
97
|
+
};
|
|
98
|
+
}, [resendCooldown]);
|
|
99
|
+
|
|
100
|
+
const emailForm = useForm<EmailFormData>({
|
|
101
|
+
resolver: zodResolver(emailSchema),
|
|
102
|
+
reValidateMode: 'onBlur',
|
|
103
|
+
});
|
|
104
|
+
const codeForm = useForm<CodeFormData>({
|
|
105
|
+
resolver: zodResolver(codeSchema),
|
|
106
|
+
reValidateMode: 'onBlur',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const [requestEmailOtp, { loading: isRequesting }] = useMutation(
|
|
110
|
+
requestEmailOtpMutation,
|
|
111
|
+
);
|
|
112
|
+
const [signInWithEmailOtp, { loading: isVerifying }] = useMutation(
|
|
113
|
+
signInWithEmailOtpMutation,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const onRequestCode = ({ email }: EmailFormData): void => {
|
|
117
|
+
requestEmailOtp({ variables: { input: { email } } })
|
|
118
|
+
.then(() => {
|
|
119
|
+
setSentToEmail(email);
|
|
120
|
+
setResendCooldown(EMAIL_OTP_RESEND_COOLDOWN_SEC);
|
|
121
|
+
// Only the code is cleared: a resend keeps any name already collected
|
|
122
|
+
// so the user does not have to type it a second time.
|
|
123
|
+
codeForm.resetField('code');
|
|
124
|
+
})
|
|
125
|
+
.catch((err: unknown) => {
|
|
126
|
+
const errorCode = getApolloErrorCode(err, ['too-many-requests']);
|
|
127
|
+
if (errorCode === 'too-many-requests') {
|
|
128
|
+
const message =
|
|
129
|
+
'Too many sign-in code requests. Please try again later.';
|
|
130
|
+
// The email form is unmounted once a code has been sent, so a
|
|
131
|
+
// rate-limited resend has nowhere to show a field error.
|
|
132
|
+
if (sentToEmail) {
|
|
133
|
+
toast.error(message);
|
|
134
|
+
} else {
|
|
135
|
+
emailForm.setError('email', { message });
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
toast.error(
|
|
140
|
+
logAndFormatError(err, 'Sorry, we could not send you a code.'),
|
|
141
|
+
);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const onVerifyCode = ({ code, name }: CodeFormData): void => {
|
|
146
|
+
if (!sentToEmail) return;
|
|
147
|
+
const trimmedName = name?.trim();
|
|
148
|
+
// Send a blank name as absent so the server answers with `name-required`
|
|
149
|
+
// rather than a validation error.
|
|
150
|
+
const nameInput = trimmedName ? trimmedName : undefined;
|
|
151
|
+
if (needsName && !nameInput) {
|
|
152
|
+
codeForm.setError(
|
|
153
|
+
'name',
|
|
154
|
+
{ message: 'Please enter your name' },
|
|
155
|
+
{ shouldFocus: true },
|
|
156
|
+
);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
signInWithEmailOtp({
|
|
160
|
+
variables: { input: { email: sentToEmail, code, name: nameInput } },
|
|
161
|
+
})
|
|
162
|
+
.then(({ data }) => {
|
|
163
|
+
if (!data) {
|
|
164
|
+
throw new Error('No data returned from sign-in mutation');
|
|
165
|
+
}
|
|
166
|
+
const { userId } = data.signInWithEmailOtp.session;
|
|
167
|
+
userSessionClient.signIn(userId);
|
|
168
|
+
|
|
169
|
+
navigate({ to: return_to ?? '/', replace: true }).catch(logError);
|
|
170
|
+
})
|
|
171
|
+
.catch((err: unknown) => {
|
|
172
|
+
const errorCode = getApolloErrorCode(err, [
|
|
173
|
+
'invalid-code',
|
|
174
|
+
'name-required',
|
|
175
|
+
'too-many-requests',
|
|
176
|
+
'verification-context-missing',
|
|
177
|
+
] as const);
|
|
178
|
+
switch (errorCode) {
|
|
179
|
+
case 'invalid-code': {
|
|
180
|
+
codeForm.setError(
|
|
181
|
+
'code',
|
|
182
|
+
{ message: 'That code is incorrect or has expired' },
|
|
183
|
+
{ shouldFocus: true },
|
|
184
|
+
);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
case 'verification-context-missing': {
|
|
188
|
+
codeForm.setError('code', {
|
|
189
|
+
message:
|
|
190
|
+
'Codes can only be used in the browser that requested them. Request a new one to continue.',
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
case 'name-required': {
|
|
195
|
+
// The code is still valid — collect a name and submit it again.
|
|
196
|
+
setNeedsName(true);
|
|
197
|
+
codeForm.setError(
|
|
198
|
+
'name',
|
|
199
|
+
{ message: 'Please enter your name' },
|
|
200
|
+
{ shouldFocus: true },
|
|
201
|
+
);
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
case 'too-many-requests': {
|
|
205
|
+
codeForm.setError('code', {
|
|
206
|
+
message: 'Too many attempts. Please try again later.',
|
|
207
|
+
});
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
case null: {
|
|
211
|
+
toast.error(
|
|
212
|
+
logAndFormatError(err, 'Sorry, we could not sign you in.'),
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<Card>
|
|
221
|
+
<CardHeader>
|
|
222
|
+
<CardTitle>
|
|
223
|
+
{!sentToEmail && 'Sign in with a code'}
|
|
224
|
+
{sentToEmail &&
|
|
225
|
+
(needsName ? 'Finish creating your account' : 'Enter your code')}
|
|
226
|
+
</CardTitle>
|
|
227
|
+
<CardDescription>
|
|
228
|
+
{!sentToEmail &&
|
|
229
|
+
`We'll email you a code so you can sign in without a password.`}
|
|
230
|
+
{sentToEmail &&
|
|
231
|
+
(needsName
|
|
232
|
+
? 'Your code checked out — tell us your name to finish setting up your account.'
|
|
233
|
+
: `We sent a ${EMAIL_OTP_LENGTH}-digit code to ${sentToEmail}.`)}
|
|
234
|
+
</CardDescription>
|
|
235
|
+
</CardHeader>
|
|
236
|
+
<CardContent>
|
|
237
|
+
{sentToEmail ? (
|
|
238
|
+
<form onSubmit={codeForm.handleSubmit(onVerifyCode)}>
|
|
239
|
+
<div className="flex flex-col items-center gap-4">
|
|
240
|
+
<InputOtpFieldController
|
|
241
|
+
control={codeForm.control}
|
|
242
|
+
name="code"
|
|
243
|
+
length={EMAIL_OTP_LENGTH}
|
|
244
|
+
/>
|
|
245
|
+
{needsName && (
|
|
246
|
+
<InputFieldController
|
|
247
|
+
control={codeForm.control}
|
|
248
|
+
name="name"
|
|
249
|
+
label="Your name"
|
|
250
|
+
autoComplete="name"
|
|
251
|
+
className="w-full"
|
|
252
|
+
/>
|
|
253
|
+
)}
|
|
254
|
+
<Button type="submit" className="w-full" disabled={isVerifying}>
|
|
255
|
+
{needsName ? 'Create account' : 'Sign in'}
|
|
256
|
+
</Button>
|
|
257
|
+
</div>
|
|
258
|
+
<div className="mt-4 flex flex-col gap-4 text-center text-sm">
|
|
259
|
+
<button
|
|
260
|
+
type="button"
|
|
261
|
+
className="text-muted-foreground underline-offset-4 hover:underline disabled:no-underline disabled:opacity-70"
|
|
262
|
+
disabled={resendCooldown > 0 || isRequesting}
|
|
263
|
+
onClick={() => {
|
|
264
|
+
onRequestCode({ email: sentToEmail });
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
{resendCooldown > 0
|
|
268
|
+
? `Resend code in ${resendCooldown}s`
|
|
269
|
+
: 'Resend code'}
|
|
270
|
+
</button>
|
|
271
|
+
<button
|
|
272
|
+
type="button"
|
|
273
|
+
className="text-muted-foreground underline-offset-4 hover:underline"
|
|
274
|
+
onClick={() => {
|
|
275
|
+
setSentToEmail(undefined);
|
|
276
|
+
setNeedsName(false);
|
|
277
|
+
}}
|
|
278
|
+
>
|
|
279
|
+
Use a different email
|
|
280
|
+
</button>
|
|
281
|
+
</div>
|
|
282
|
+
</form>
|
|
283
|
+
) : (
|
|
284
|
+
<form onSubmit={emailForm.handleSubmit(onRequestCode)}>
|
|
285
|
+
<div className="flex flex-col gap-4">
|
|
286
|
+
<InputFieldController
|
|
287
|
+
control={emailForm.control}
|
|
288
|
+
name="email"
|
|
289
|
+
type="email"
|
|
290
|
+
autoComplete="email"
|
|
291
|
+
placeholder="user@example.com"
|
|
292
|
+
/>
|
|
293
|
+
<Button type="submit" className="w-full" disabled={isRequesting}>
|
|
294
|
+
Email me a code
|
|
295
|
+
</Button>
|
|
296
|
+
</div>
|
|
297
|
+
<div className="mt-4 flex flex-col gap-4 text-center text-sm">
|
|
298
|
+
<Link
|
|
299
|
+
to="/auth/login"
|
|
300
|
+
search={{ return_to }}
|
|
301
|
+
className="text-muted-foreground underline-offset-4 hover:underline"
|
|
302
|
+
>
|
|
303
|
+
Sign in with a password instead
|
|
304
|
+
</Link>
|
|
305
|
+
</div>
|
|
306
|
+
</form>
|
|
307
|
+
)}
|
|
308
|
+
</CardContent>
|
|
309
|
+
</Card>
|
|
310
|
+
);
|
|
311
|
+
}
|
|
@@ -95,6 +95,6 @@ function LoginPage() {
|
|
|
95
95
|
}
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
|
-
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Login to your account" }), _jsx(CardDescription, { children: "Enter your email below to login to your account" })] }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit(onSubmit), children: [_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(InputFieldController, { control: control, name: "email", type: "email", autoComplete: "email", placeholder: "user@example.com" }), _jsx(InputFieldController, { control: control, name: "password", type: "password", autoComplete: "current-password", placeholder: "Password" }), _jsx(Button, { type: "submit", className: "w-full", disabled: loading, children: "Login" })] }), _jsxs("div", { className: "mt-4 flex flex-col gap-4 text-center text-sm", children: [_jsx(Link, { to: "/auth/forgot-password", className: "text-muted-foreground underline-offset-4 hover:underline", children: "Forgot your password?" }),
|
|
98
|
+
return (_jsxs(Card, { children: [_jsxs(CardHeader, { children: [_jsx(CardTitle, { children: "Login to your account" }), _jsx(CardDescription, { children: "Enter your email below to login to your account" })] }), _jsx(CardContent, { children: _jsxs("form", { onSubmit: handleSubmit(onSubmit), children: [_jsxs("div", { className: "flex flex-col gap-4", children: [_jsx(InputFieldController, { control: control, name: "email", type: "email", autoComplete: "email", placeholder: "user@example.com" }), _jsx(InputFieldController, { control: control, name: "password", type: "password", autoComplete: "current-password", placeholder: "Password" }), _jsx(Button, { type: "submit", className: "w-full", disabled: loading, children: "Login" })] }), _jsxs("div", { className: "mt-4 flex flex-col gap-4 text-center text-sm", children: [_jsx(TPL_OTP_LOGIN_LINK, {}), _jsx(Link, { to: "/auth/forgot-password", className: "text-muted-foreground underline-offset-4 hover:underline", children: "Forgot your password?" }), _jsx(TPL_REGISTER_LINK, {})] })] }) })] }));
|
|
99
99
|
}
|
|
100
100
|
//# sourceMappingURL=login.js.map
|
|
@@ -164,21 +164,14 @@ function LoginPage(): React.JSX.Element {
|
|
|
164
164
|
</Button>
|
|
165
165
|
</div>
|
|
166
166
|
<div className="mt-4 flex flex-col gap-4 text-center text-sm">
|
|
167
|
+
<TPL_OTP_LOGIN_LINK />
|
|
167
168
|
<Link
|
|
168
169
|
to="/auth/forgot-password"
|
|
169
170
|
className="text-muted-foreground underline-offset-4 hover:underline"
|
|
170
171
|
>
|
|
171
172
|
Forgot your password?
|
|
172
173
|
</Link>
|
|
173
|
-
<
|
|
174
|
-
Don't have an account?{' '}
|
|
175
|
-
<Link
|
|
176
|
-
to="/auth/register"
|
|
177
|
-
className="underline underline-offset-4"
|
|
178
|
-
>
|
|
179
|
-
Sign up
|
|
180
|
-
</Link>
|
|
181
|
-
</div>
|
|
174
|
+
<TPL_REGISTER_LINK />
|
|
182
175
|
</div>
|
|
183
176
|
</form>
|
|
184
177
|
</CardContent>
|
|
@@ -163,6 +163,12 @@ export declare const LOCAL_AUTH_CORE_REACT_SESSION_GENERATED: {
|
|
|
163
163
|
InputGroupInput: {};
|
|
164
164
|
InputGroupText: {};
|
|
165
165
|
InputGroupTextarea: {};
|
|
166
|
+
InputOtp: {};
|
|
167
|
+
InputOtpField: {};
|
|
168
|
+
InputOtpFieldController: {};
|
|
169
|
+
InputOtpGroup: {};
|
|
170
|
+
InputOtpSeparator: {};
|
|
171
|
+
InputOtpSlot: {};
|
|
166
172
|
inputVariants: {};
|
|
167
173
|
Item: {};
|
|
168
174
|
ItemActions: {};
|
|
@@ -438,6 +444,12 @@ export declare const LOCAL_AUTH_CORE_REACT_SESSION_GENERATED: {
|
|
|
438
444
|
InputGroupInput: {};
|
|
439
445
|
InputGroupText: {};
|
|
440
446
|
InputGroupTextarea: {};
|
|
447
|
+
InputOtp: {};
|
|
448
|
+
InputOtpField: {};
|
|
449
|
+
InputOtpFieldController: {};
|
|
450
|
+
InputOtpGroup: {};
|
|
451
|
+
InputOtpSeparator: {};
|
|
452
|
+
InputOtpSlot: {};
|
|
441
453
|
inputVariants: {};
|
|
442
454
|
Item: {};
|
|
443
455
|
ItemActions: {};
|
|
@@ -152,6 +152,12 @@ export declare const LOCAL_AUTH_CORE_REACT_SESSION_RENDERERS: {
|
|
|
152
152
|
InputGroupInput: {};
|
|
153
153
|
InputGroupText: {};
|
|
154
154
|
InputGroupTextarea: {};
|
|
155
|
+
InputOtp: {};
|
|
156
|
+
InputOtpField: {};
|
|
157
|
+
InputOtpFieldController: {};
|
|
158
|
+
InputOtpGroup: {};
|
|
159
|
+
InputOtpSeparator: {};
|
|
160
|
+
InputOtpSlot: {};
|
|
155
161
|
inputVariants: {};
|
|
156
162
|
Item: {};
|
|
157
163
|
ItemActions: {};
|
|
@@ -145,6 +145,12 @@ export declare const mainGroup: {
|
|
|
145
145
|
InputGroupInput: {};
|
|
146
146
|
InputGroupText: {};
|
|
147
147
|
InputGroupTextarea: {};
|
|
148
|
+
InputOtp: {};
|
|
149
|
+
InputOtpField: {};
|
|
150
|
+
InputOtpFieldController: {};
|
|
151
|
+
InputOtpGroup: {};
|
|
152
|
+
InputOtpSeparator: {};
|
|
153
|
+
InputOtpSlot: {};
|
|
148
154
|
inputVariants: {};
|
|
149
155
|
Item: {};
|
|
150
156
|
ItemActions: {};
|
|
@@ -418,6 +424,12 @@ export declare const LOCAL_AUTH_CORE_REACT_SESSION_TEMPLATES: {
|
|
|
418
424
|
InputGroupInput: {};
|
|
419
425
|
InputGroupText: {};
|
|
420
426
|
InputGroupTextarea: {};
|
|
427
|
+
InputOtp: {};
|
|
428
|
+
InputOtpField: {};
|
|
429
|
+
InputOtpFieldController: {};
|
|
430
|
+
InputOtpGroup: {};
|
|
431
|
+
InputOtpSeparator: {};
|
|
432
|
+
InputOtpSlot: {};
|
|
421
433
|
inputVariants: {};
|
|
422
434
|
Item: {};
|
|
423
435
|
ItemActions: {};
|
|
@@ -159,6 +159,12 @@ export declare const reactSessionGenerator: import("@baseplate-dev/sync").Genera
|
|
|
159
159
|
InputGroupInput: {};
|
|
160
160
|
InputGroupText: {};
|
|
161
161
|
InputGroupTextarea: {};
|
|
162
|
+
InputOtp: {};
|
|
163
|
+
InputOtpField: {};
|
|
164
|
+
InputOtpFieldController: {};
|
|
165
|
+
InputOtpGroup: {};
|
|
166
|
+
InputOtpSeparator: {};
|
|
167
|
+
InputOtpSlot: {};
|
|
162
168
|
inputVariants: {};
|
|
163
169
|
Item: {};
|
|
164
170
|
ItemActions: {};
|