@wasp.sh/wasp-cli-darwin-x64-unknown 0.25.0-rc.1 → 0.26.0-rc.1
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/data/Cli/starters/README.md +2 -0
- package/data/Cli/starters/basic/README.md +3 -3
- package/data/Cli/starters/basic/src/tags/components/CreateTagForm.tsx +2 -3
- package/data/Cli/starters/basic/vite.config.ts +0 -3
- package/data/Cli/starters/minimal/package.json +4 -1
- package/data/Cli/starters/minimal/vite.config.ts +0 -3
- package/data/Cli/starters/skeleton/AGENTS.md +6 -0
- package/data/Cli/starters/skeleton/CLAUDE.md +6 -0
- package/data/Cli/starters/skeleton/tsconfig.src.json +1 -11
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/node_modules/@wasp.sh/lib-auth/wasp.sh-lib-auth-0.26.0.tgz +0 -0
- package/data/Generator/libs/sdk-core/wasp.sh-lib-sdk-core-0.26.0.tgz +0 -0
- package/data/Generator/libs/vite-ssr/{wasp.sh-lib-vite-ssr-0.25.0.tgz → wasp.sh-lib-vite-ssr-0.26.0.tgz} +0 -0
- package/data/Generator/templates/Dockerfile +1 -0
- package/data/Generator/templates/sdk/wasp/api/index.ts +5 -86
- package/data/Generator/templates/sdk/wasp/auth/email/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/email/actions/passwordReset.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/email/actions/signup.ts +7 -6
- package/data/Generator/templates/sdk/wasp/auth/email/actions/verifyEmail.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Auth.tsx +12 -6
- package/data/Generator/templates/sdk/wasp/auth/forms/ForgotPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Login.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/ResetPassword.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/Signup.tsx +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/VerifyEmail.tsx +2 -1
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/common/LoginSignupForm.tsx +34 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.module.css +11 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.tsx +17 -0
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ForgotPasswordForm.tsx +9 -13
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/ResetPasswordForm.tsx +8 -9
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/VerifyEmailForm.tsx +4 -8
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/useEmail.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/usernameAndPassword/useUsernameAndPassword.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/types.ts +0 -59
- package/data/Generator/templates/sdk/wasp/auth/helpers/_Provider.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/auth/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/logout.ts +1 -1
- package/data/Generator/templates/sdk/wasp/auth/providers/index.ts +4 -4
- package/data/Generator/templates/sdk/wasp/auth/providers/types.ts +20 -24
- package/data/Generator/templates/sdk/wasp/auth/useAuth.ts +5 -5
- package/data/Generator/templates/sdk/wasp/auth/user.ts +147 -14
- package/data/Generator/templates/sdk/wasp/auth/username/actions/login.ts +2 -2
- package/data/Generator/templates/sdk/wasp/auth/username/actions/signup.ts +6 -5
- package/data/Generator/templates/sdk/wasp/auth/validation.ts +1 -83
- package/data/Generator/templates/sdk/wasp/client/app/pages/OAuthCallback.tsx +8 -5
- package/data/Generator/templates/sdk/wasp/client/app/pages/createAuthRequiredPage.jsx +6 -4
- package/data/Generator/templates/sdk/wasp/client/app/router.tsx +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/ui.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/auth/username.ts +2 -2
- package/data/Generator/templates/sdk/wasp/client/config.ts +1 -6
- package/data/Generator/templates/sdk/wasp/client/crud/_crud.ts +129 -75
- package/data/Generator/templates/sdk/wasp/client/env/schema.ts +14 -7
- package/data/Generator/templates/sdk/wasp/client/env.ts +4 -3
- package/data/Generator/templates/sdk/wasp/client/index.ts +3 -12
- package/data/Generator/templates/sdk/wasp/client/operations/actions/core.ts +14 -10
- package/data/Generator/templates/sdk/wasp/client/operations/actions/index.ts +7 -4
- package/data/Generator/templates/sdk/wasp/client/operations/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/client/operations/internal/index.ts +1 -8
- package/data/Generator/templates/sdk/wasp/client/operations/queries/core.ts +13 -55
- package/data/Generator/templates/sdk/wasp/client/operations/queries/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/client/router/Link.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/NavLink.tsx +8 -8
- package/data/Generator/templates/sdk/wasp/client/router/index.ts +15 -15
- package/data/Generator/templates/sdk/wasp/client/test/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/test/vitest/helpers.tsx +5 -36
- package/data/Generator/templates/sdk/wasp/client/vite/index.ts +2 -1
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/virtualUserModules.ts +43 -0
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/{virtualModules.ts → virtualWaspModules.ts} +4 -4
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/wasp.ts +17 -14
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/waspConfig.ts +60 -18
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/client-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/routes.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/files/ssr-entry.tsx +1 -1
- package/data/Generator/templates/sdk/wasp/client/webSocket/WebSocketProvider.tsx +3 -3
- package/data/Generator/templates/sdk/wasp/client/webSocket/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/core/serialization/index.ts +2 -47
- package/data/Generator/templates/sdk/wasp/core/serialization/prisma.ts +0 -1
- package/data/Generator/templates/sdk/wasp/entities/index.ts +6 -6
- package/data/Generator/templates/sdk/wasp/env/index.ts +1 -9
- package/data/Generator/templates/sdk/wasp/package.json +150 -104
- package/data/Generator/templates/sdk/wasp/server/_types/index.ts +8 -10
- package/data/Generator/templates/sdk/wasp/server/_types/taggedEntities.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/api/index.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/auth/email/index.ts +2 -12
- package/data/Generator/templates/sdk/wasp/server/auth/email/utils.ts +8 -30
- package/data/Generator/templates/sdk/wasp/server/auth/hooks.ts +5 -2
- package/data/Generator/templates/sdk/wasp/server/auth/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/jwt.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/lucia.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/oneTimeCode.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/discord.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/github.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/google.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/keycloak.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/microsoft.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/providers/slack.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/session.ts +17 -6
- package/data/Generator/templates/sdk/wasp/{auth → server/auth}/utils.ts +40 -183
- package/data/Generator/templates/sdk/wasp/server/config.ts +1 -1
- package/data/Generator/templates/sdk/wasp/{core → server/core}/auth.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/crud/_operationTypes.ts +16 -63
- package/data/Generator/templates/sdk/wasp/server/dbClient.ts +15 -17
- package/data/Generator/templates/sdk/wasp/server/email/core/helpers.ts +3 -20
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/dummy.ts +2 -2
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/resend.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/providers/smtp.ts +2 -1
- package/data/Generator/templates/sdk/wasp/server/email/core/types.ts +2 -45
- package/data/Generator/templates/sdk/wasp/server/email/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/env.ts +20 -11
- package/data/Generator/templates/sdk/wasp/server/index.ts +3 -3
- package/data/Generator/templates/sdk/wasp/server/jobs/_job.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/pgBossJob.ts +4 -4
- package/data/Generator/templates/sdk/wasp/server/jobs/core/pgBoss/types.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/middleware/index.ts +1 -1
- package/data/Generator/templates/sdk/wasp/server/operations/actions/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/actions/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/queries/index.ts +14 -8
- package/data/Generator/templates/sdk/wasp/server/operations/queries/types.ts +5 -5
- package/data/Generator/templates/sdk/wasp/server/operations/wrappers.ts +40 -14
- package/data/Generator/templates/sdk/wasp/server/types/index.ts +1 -11
- package/data/Generator/templates/sdk/wasp/server/utils.ts +5 -20
- package/data/Generator/templates/sdk/wasp/server/webSocket/index.ts +7 -7
- package/data/Generator/templates/sdk/wasp/tsconfig.json +20 -46
- package/data/Generator/templates/sdk/wasp/types/index.ts +8 -0
- package/data/Generator/templates/sdk/wasp/types/register.ts +21 -0
- package/data/Generator/templates/sdk/wasp/vite-env.d.ts +0 -9
- package/data/Generator/templates/sdk/wasp/wasp-ssr.d.ts +8 -0
- package/data/Generator/templates/sdk/wasp/wasp-user-virtual-modules.d.ts +20 -0
- package/data/Generator/templates/server/package.json +2 -1
- package/data/Generator/templates/server/rollup.config.js +2 -43
- package/data/Generator/templates/server/rollup.dbSeed.config.js +3 -0
- package/data/Generator/templates/server/src/app.js +2 -2
- package/data/Generator/templates/server/src/auth/providers/config/email.ts +5 -5
- package/data/Generator/templates/server/src/auth/providers/email/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/requestPasswordReset.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/email/resetPassword.ts +13 -5
- package/data/Generator/templates/server/src/auth/providers/email/signup.ts +29 -18
- package/data/Generator/templates/server/src/auth/providers/email/verifyEmail.ts +7 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/cookies.ts +5 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/handler.ts +1 -1
- package/data/Generator/templates/server/src/auth/providers/oauth/oneTimeCode.ts +2 -2
- package/data/Generator/templates/server/src/auth/providers/oauth/state.ts +55 -13
- package/data/Generator/templates/server/src/auth/providers/oauth/user.ts +6 -3
- package/data/Generator/templates/server/src/auth/providers/username/login.ts +4 -4
- package/data/Generator/templates/server/src/auth/providers/username/signup.ts +12 -4
- package/data/Generator/templates/server/src/createRollupBundle.js +47 -0
- package/data/Generator/templates/server/src/crud/_operations.ts +16 -16
- package/data/Generator/templates/server/src/plugins/virtualUserModules.js +40 -0
- package/data/Generator/templates/server/src/routes/apis/index.ts +3 -3
- package/data/Generator/templates/server/src/routes/auth/index.js +1 -1
- package/data/Generator/templates/server/src/routes/auth/logout.ts +2 -2
- package/data/Generator/templates/server/src/routes/crud/_crud.ts +1 -1
- package/data/Generator/templates/server/src/routes/index.js +18 -18
- package/data/Generator/templates/server/src/routes/operations/index.js +1 -1
- package/data/Generator/templates/server/src/webSocket/initialization.ts +1 -1
- package/data/Generator/templates/server/tsconfig.json +7 -13
- package/data/Generator/templates/types/app/sdk/register.ts +57 -0
- package/data/packages/deploy/dist/common/cliVersion.js +17 -0
- package/data/packages/deploy/dist/common/waspProject.js +1 -1
- package/data/packages/deploy/dist/common/zx.js +24 -6
- package/data/packages/deploy/dist/providers/fly/commands/createDb/createDb.js +13 -5
- package/data/packages/deploy/dist/providers/fly/flyCli.js +29 -17
- package/data/packages/deploy/dist/providers/fly/index.js +16 -8
- package/data/packages/deploy/dist/providers/railway/commands/setup/setup.js +19 -31
- package/data/packages/deploy/dist/providers/railway/index.js +11 -2
- package/data/packages/deploy/dist/providers/railway/jsonOutputSchemas.js +19 -34
- package/data/packages/deploy/dist/providers/railway/railwayCli.js +11 -20
- package/data/packages/deploy/dist/providers/railway/railwayEnvironment/cli.js +20 -0
- package/data/packages/deploy/dist/providers/railway/railwayProject/RailwayProject.js +4 -1
- package/data/packages/deploy/dist/providers/railway/railwayProject/cli.js +6 -14
- package/data/packages/deploy/dist/providers/railway/railwayService/database.js +88 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/deployment.js +12 -25
- package/data/packages/deploy/dist/providers/railway/railwayService/nameGenerator.js +5 -4
- package/data/packages/deploy/dist/providers/railway/railwayService/serviceInstance.js +48 -0
- package/data/packages/deploy/dist/providers/railway/railwayService/url.js +9 -30
- package/data/packages/deploy/package-lock.json +2 -2
- package/data/packages/deploy/package.json +1 -1
- package/data/packages/prisma/package-lock.json +2 -2
- package/data/packages/prisma/package.json +1 -1
- package/data/packages/spec/dist/__tests__/spec/mapApp.unit.test.js +19 -15
- package/data/packages/spec/dist/__tests__/spec/tsAppSpec.test-d.js +6 -0
- package/data/packages/spec/dist/src/appSpec.d.ts +15 -2
- package/data/packages/spec/dist/src/appSpec.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts +1 -0
- package/data/packages/spec/dist/src/spec/mapper/app.d.ts.map +1 -1
- package/data/packages/spec/dist/src/spec/mapper/app.js +8 -2
- package/data/packages/spec/dist/src/spec/mapper/context.js +4 -4
- package/data/packages/spec/dist/src/spec/mapper/specElements.js +9 -9
- package/data/packages/spec/dist/src/spec/publicApi/constructors.d.ts +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/constructors.js +11 -11
- package/data/packages/spec/dist/src/spec/publicApi/register.d.ts +1 -1
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts +58 -38
- package/data/packages/spec/dist/src/spec/publicApi/waspSpec.d.ts.map +1 -1
- package/data/packages/spec/package-lock.json +2 -2
- package/data/packages/spec/package.json +1 -1
- package/data/packages/studio/package-lock.json +15 -23
- package/data/packages/studio/package.json +2 -2
- package/package.json +1 -1
- package/wasp-bin +0 -0
- package/data/Generator/libs/auth/wasp.sh-lib-auth-0.25.0.tgz +0 -0
- package/data/Generator/templates/sdk/wasp/api/events.ts +0 -11
- package/data/Generator/templates/sdk/wasp/auth/email/index.ts +0 -5
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.module.css +0 -99
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Form.tsx +0 -74
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.module.css +0 -22
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/Message.tsx +0 -34
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/auth-styles.css +0 -30
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.module.css +0 -33
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialButton.tsx +0 -14
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.module.css +0 -4
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/social/SocialIcons.tsx +0 -85
- package/data/Generator/templates/sdk/wasp/auth/forms/internal/util.ts +0 -16
- package/data/Generator/templates/sdk/wasp/auth/helpers/user.ts +0 -15
- package/data/Generator/templates/sdk/wasp/auth/responseSchemas.ts +0 -10
- package/data/Generator/templates/sdk/wasp/auth/types.ts +0 -2
- package/data/Generator/templates/sdk/wasp/auth/username/index.ts +0 -2
- package/data/Generator/templates/sdk/wasp/client/app/components/DefaultRootErrorBoundary.tsx +0 -16
- package/data/Generator/templates/sdk/wasp/client/app/components/FullPageWrapper.tsx +0 -21
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.module.css +0 -37
- package/data/Generator/templates/sdk/wasp/client/app/components/Loader.tsx +0 -12
- package/data/Generator/templates/sdk/wasp/client/app/components/Message.tsx +0 -86
- package/data/Generator/templates/sdk/wasp/client/crud/operationsHelpers.ts +0 -21
- package/data/Generator/templates/sdk/wasp/client/hooks.ts +0 -19
- package/data/Generator/templates/sdk/wasp/client/operations/hooks.ts +0 -347
- package/data/Generator/templates/sdk/wasp/client/operations/internal/resources.js +0 -85
- package/data/Generator/templates/sdk/wasp/client/operations/internal/updateHandlersMap.js +0 -37
- package/data/Generator/templates/sdk/wasp/client/operations/queryClient.ts +0 -34
- package/data/Generator/templates/sdk/wasp/client/operations/rpc.ts +0 -96
- package/data/Generator/templates/sdk/wasp/client/router/linkHelpers.ts +0 -48
- package/data/Generator/templates/sdk/wasp/client/router/types.ts +0 -98
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/detectServerImports.ts +0 -50
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/envFile.ts +0 -112
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/typescriptCheck.ts +0 -36
- package/data/Generator/templates/sdk/wasp/client/vite/plugins/validateEnv.ts +0 -88
- package/data/Generator/templates/sdk/wasp/client/vite/virtual-files/resolver.ts +0 -35
- package/data/Generator/templates/sdk/wasp/core/serialization/custom-register.ts +0 -21
- package/data/Generator/templates/sdk/wasp/core/storage.ts +0 -73
- package/data/Generator/templates/sdk/wasp/env/validation.ts +0 -44
- package/data/Generator/templates/sdk/wasp/server/HttpError.ts +0 -30
- package/data/Generator/templates/sdk/wasp/server/auth/oauth/provider.ts +0 -20
- package/data/Generator/templates/sdk/wasp/server/auth/user.ts +0 -154
- package/data/Generator/templates/sdk/wasp/server/auth/username.ts +0 -1
- package/data/Generator/templates/sdk/wasp/server/jobs/core/job.ts +0 -28
- package/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts +0 -8
- package/data/Generator/templates/sdk/wasp/universal/ansiColors.ts +0 -58
- package/data/Generator/templates/sdk/wasp/universal/predicates.ts +0 -3
- package/data/Generator/templates/sdk/wasp/universal/types.ts +0 -74
- package/data/Generator/templates/sdk/wasp/universal/url.ts +0 -9
- package/data/Generator/templates/sdk/wasp/universal/validators.ts +0 -21
- package/data/packages/ts-inspect/dist/exports.js +0 -82
- package/data/packages/ts-inspect/dist/index.js +0 -28
- package/data/packages/ts-inspect/package-lock.json +0 -4724
- package/data/packages/ts-inspect/package.json +0 -31
- /package/data/Generator/templates/sdk/wasp/{auth → server/auth}/password.ts +0 -0
|
@@ -20,3 +20,5 @@ The recommended approach for developing starter templates:
|
|
|
20
20
|
2. **Implement changes**: Make your required changes in the Wasp project
|
|
21
21
|
3. **Copy changes back**: Once satisfied with the implementation, copy the files from your project back to the starter templates
|
|
22
22
|
4. **Test the starter**: Create a new project with `wasp-cli` to verify it matches your previously created project
|
|
23
|
+
|
|
24
|
+
When copying changes back, don't include the `migrations/` directory. Starters intentionally ship without migrations so users aren't locked into a specific database provider. They'll get a single clean initial migration when they run `wasp db migrate-dev` for the first time.
|
|
@@ -22,14 +22,14 @@ wasp new <project-name> -t basic
|
|
|
22
22
|
|
|
23
23
|
## Development
|
|
24
24
|
|
|
25
|
+
After cloning the project, run `wasp install`.
|
|
26
|
+
|
|
25
27
|
To start the application locally for development or preview purposes:
|
|
26
28
|
|
|
27
29
|
1. Run `wasp db migrate-dev` to migrate the database to the latest migration
|
|
28
|
-
2. Run `wasp start` to start the Wasp application.
|
|
30
|
+
2. Run `wasp start` to start the Wasp application.
|
|
29
31
|
3. The application should be running on `localhost:3000`. Open in it your browser to access the client.
|
|
30
32
|
|
|
31
|
-
To improve your Wasp development experience, we recommend installing the [Wasp extension for VSCode](https://marketplace.visualstudio.com/items?itemName=wasp-lang.wasp).
|
|
32
|
-
|
|
33
33
|
## Learn more
|
|
34
34
|
|
|
35
35
|
To find out more about Wasp, visit out [docs](https://wasp.sh/docs).
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { FormEvent } from "react";
|
|
2
1
|
import { Controller, SubmitHandler, useForm } from "react-hook-form";
|
|
3
2
|
import { createTag } from "wasp/client/operations";
|
|
4
3
|
import { Input } from "../../shared/components/Input";
|
|
@@ -90,8 +89,8 @@ export function CreateTagForm({ id, onTagCreated }: CreateTagFormProps) {
|
|
|
90
89
|
*
|
|
91
90
|
* @see https://github.com/react-hook-form/documentation/issues/916
|
|
92
91
|
*/
|
|
93
|
-
function stopPropagate(callback: (event:
|
|
94
|
-
return (e:
|
|
92
|
+
function stopPropagate(callback: (event: React.SubmitEvent<HTMLFormElement>) => void) {
|
|
93
|
+
return (e: React.SubmitEvent<HTMLFormElement>) => {
|
|
95
94
|
e.stopPropagation();
|
|
96
95
|
callback(e);
|
|
97
96
|
};
|
|
@@ -17,6 +17,12 @@ This project uses the Wasp framework.
|
|
|
17
17
|
- Other constructors take no name argument; the declaration's name is the imported identifier. For example, `job(sendReminder, { ... })` declares a job named `sendReminder`.
|
|
18
18
|
- `@wasp.sh/spec` is generated by Wasp, don't install it from npm.
|
|
19
19
|
|
|
20
|
+
### Fresh checkout
|
|
21
|
+
|
|
22
|
+
- Run `wasp install` before other Wasp commands in a fresh clone or worktree.
|
|
23
|
+
- Set up `.env.server` and `.env.client` from the example files or the project README.
|
|
24
|
+
- Run `wasp db migrate-dev`. Check the project README to see whether you also need to run a seed.
|
|
25
|
+
|
|
20
26
|
### Verification
|
|
21
27
|
|
|
22
28
|
- Run `wasp compile` to check if app is valid.
|
|
@@ -17,6 +17,12 @@ This project uses the Wasp framework.
|
|
|
17
17
|
- Other constructors take no name argument; the declaration's name is the imported identifier. For example, `job(sendReminder, { ... })` declares a job named `sendReminder`.
|
|
18
18
|
- `@wasp.sh/spec` is generated by Wasp, don't install it from npm.
|
|
19
19
|
|
|
20
|
+
### Fresh checkout
|
|
21
|
+
|
|
22
|
+
- Run `wasp install` before other Wasp commands in a fresh clone or worktree.
|
|
23
|
+
- Set up `.env.server` and `.env.client` from the example files or the project README.
|
|
24
|
+
- Run `wasp db migrate-dev`. Check the project README to see whether you also need to run a seed.
|
|
25
|
+
|
|
20
26
|
### Verification
|
|
21
27
|
|
|
22
28
|
- Run `wasp compile` to check if app is valid.
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
// =============================== IMPORTANT =================================
|
|
2
|
-
// This file is mainly used for Wasp IDE support.
|
|
3
|
-
//
|
|
4
|
-
// Wasp will compile your code with slightly different (less strict) compilerOptions.
|
|
5
|
-
// You can increase the configuration's strictness (e.g., by adding
|
|
6
|
-
// "noUncheckedIndexedAccess": true), but you shouldn't reduce it (e.g., by
|
|
7
|
-
// adding "strict": false). Just keep in mind that this will only affect your
|
|
8
|
-
// IDE support, not the actual compilation.
|
|
9
|
-
//
|
|
10
|
-
// Full TypeScript configurability is coming very soon :)
|
|
11
1
|
{
|
|
12
2
|
"compilerOptions": {
|
|
13
3
|
"module": "esnext",
|
|
@@ -25,6 +15,6 @@
|
|
|
25
15
|
"outDir": ".wasp/out/user",
|
|
26
16
|
"types": ["react", "node"]
|
|
27
17
|
},
|
|
28
|
-
"include": ["src"],
|
|
18
|
+
"include": ["src", ".wasp/out/types/app"],
|
|
29
19
|
"exclude": ["**/*.wasp.ts"]
|
|
30
20
|
}
|
|
Binary file
|
package/data/Generator/libs/sdk-core/node_modules/@wasp.sh/lib-auth/wasp.sh-lib-auth-0.26.0.tgz
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -40,6 +40,7 @@ COPY package-lock.json .
|
|
|
40
40
|
COPY tsconfig*.json .
|
|
41
41
|
COPY server .wasp/out/server
|
|
42
42
|
COPY sdk .wasp/out/sdk
|
|
43
|
+
COPY types .wasp/out/types
|
|
43
44
|
COPY libs .wasp/out/libs
|
|
44
45
|
# Install npm packages, resulting in node_modules/.
|
|
45
46
|
RUN npm install && cd .wasp/out/server && npm install
|
|
@@ -1,34 +1,8 @@
|
|
|
1
|
-
import ky
|
|
2
|
-
import { config } from '../client/
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const WASP_APP_AUTH_SESSION_ID_NAME = 'sessionId'
|
|
7
|
-
|
|
8
|
-
// PRIVATE API (sdk)
|
|
9
|
-
export function setSessionId(sessionId: string): void {
|
|
10
|
-
storage.set(WASP_APP_AUTH_SESSION_ID_NAME, sessionId)
|
|
11
|
-
apiEventsEmitter.emit('sessionId.set')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// PRIVATE API (sdk)
|
|
15
|
-
export function getSessionId(): string | null {
|
|
16
|
-
const sessionId = storage.get(WASP_APP_AUTH_SESSION_ID_NAME) as
|
|
17
|
-
| string
|
|
18
|
-
| undefined
|
|
19
|
-
return sessionId ?? null
|
|
20
|
-
}
|
|
21
|
-
// PRIVATE API (sdk)
|
|
22
|
-
export function clearSessionId(): void {
|
|
23
|
-
storage.remove(WASP_APP_AUTH_SESSION_ID_NAME)
|
|
24
|
-
apiEventsEmitter.emit('sessionId.clear')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// PRIVATE API (sdk)
|
|
28
|
-
export function removeLocalUserData(): void {
|
|
29
|
-
storage.clear()
|
|
30
|
-
apiEventsEmitter.emit('sessionId.clear')
|
|
31
|
-
}
|
|
1
|
+
import ky from 'ky'
|
|
2
|
+
import { config } from '../client/config.js'
|
|
3
|
+
import { getSessionId, clearSessionId } from '@wasp.sh/lib-sdk-core/browser'
|
|
4
|
+
export { getSessionId, setSessionId, clearSessionId, removeLocalUserData, handleApiError } from '@wasp.sh/lib-sdk-core/browser'
|
|
5
|
+
export { WaspHttpError } from '@wasp.sh/lib-sdk-core'
|
|
32
6
|
|
|
33
7
|
// PUBLIC API
|
|
34
8
|
/**
|
|
@@ -79,61 +53,6 @@ export const api = ky.extend({
|
|
|
79
53
|
},
|
|
80
54
|
})
|
|
81
55
|
|
|
82
|
-
// This makes sure that the following handler won't try to run in a non-browser
|
|
83
|
-
// environment (e.g. during SSR), where `window` is not defined.
|
|
84
|
-
if (typeof window !== 'undefined') {
|
|
85
|
-
// This handler will run on other tabs (not the active one calling API functions),
|
|
86
|
-
// and will ensure they know about auth session ID changes.
|
|
87
|
-
// Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/storage_event
|
|
88
|
-
// "Note: This won't work on the same page that is making the changes — it is really a way
|
|
89
|
-
// for other pages on the domain using the storage to sync any changes that are made."
|
|
90
|
-
window.addEventListener('storage', (event) => {
|
|
91
|
-
if (event.key === storage.getPrefixedKey(WASP_APP_AUTH_SESSION_ID_NAME)) {
|
|
92
|
-
if (!!event.newValue) {
|
|
93
|
-
apiEventsEmitter.emit('sessionId.set')
|
|
94
|
-
} else {
|
|
95
|
-
apiEventsEmitter.emit('sessionId.clear')
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
})
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// PRIVATE API (sdk)
|
|
102
|
-
/**
|
|
103
|
-
* Takes an error returned by the app's API (as thrown by ky), and transforms it into a more
|
|
104
|
-
* standard format to be further used by the client. It is also assumed that given API
|
|
105
|
-
* error has been formatted as implemented by HttpError on the server.
|
|
106
|
-
*/
|
|
107
|
-
export function handleApiError(error: unknown): unknown {
|
|
108
|
-
if (isHTTPError(error)) {
|
|
109
|
-
// If error came from HTTP response, we capture most informative message
|
|
110
|
-
// and also add .statusCode information to it.
|
|
111
|
-
// If error had JSON response, we assume it is of format { message, data } and
|
|
112
|
-
// add that info to the error.
|
|
113
|
-
// TODO: We might want to use HttpError here instead of just Error, since
|
|
114
|
-
// HttpError is also used on server to throw errors like these.
|
|
115
|
-
// That would require copying HttpError code to web-app also and using it here.
|
|
116
|
-
const responseJson = error.data as { message?: string; data?: unknown } | undefined
|
|
117
|
-
const responseStatusCode = error.response.status
|
|
118
|
-
return new WaspHttpError(responseStatusCode, responseJson?.message ?? error.message, responseJson)
|
|
119
|
-
} else {
|
|
120
|
-
// If any other error, we just propagate it.
|
|
121
|
-
return error
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
class WaspHttpError extends Error {
|
|
126
|
-
statusCode: number
|
|
127
|
-
|
|
128
|
-
data: unknown
|
|
129
|
-
|
|
130
|
-
constructor(statusCode: number, message: string, data: unknown) {
|
|
131
|
-
super(message)
|
|
132
|
-
this.statusCode = statusCode
|
|
133
|
-
this.data = data
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
56
|
function getSessionIdFromAuthorizationHeader(header: string | null): string | null {
|
|
138
57
|
const prefix = 'Bearer '
|
|
139
58
|
if (header && header.startsWith(prefix)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from '../../../api/index.js';
|
|
3
|
-
import { initSession } from '
|
|
4
|
-
import { SessionResponseSchema } from '
|
|
3
|
+
import { initSession } from '@wasp.sh/lib-sdk-core/browser';
|
|
4
|
+
import { SessionResponseSchema } from '@wasp.sh/lib-sdk-core';
|
|
5
5
|
|
|
6
6
|
// PUBLIC API
|
|
7
7
|
export async function login(data: { email: string; password: string }): Promise<void> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from '../../../api/index.js';
|
|
3
|
-
import { SuccessResponseSchema } from '
|
|
3
|
+
import { SuccessResponseSchema } from '@wasp.sh/lib-sdk-core';
|
|
4
4
|
|
|
5
5
|
// PUBLIC API
|
|
6
6
|
export async function requestPasswordReset(data: { email: string; }): Promise<{ success: boolean }> {
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
2
|
import { api, handleApiError } from '../../../api/index.js';
|
|
3
|
-
import { SuccessResponseSchema } from '
|
|
4
|
-
{=#
|
|
5
|
-
import {
|
|
6
|
-
{=/
|
|
3
|
+
import { SuccessResponseSchema } from '@wasp.sh/lib-sdk-core';
|
|
4
|
+
{=# isEmailUserSignupFieldsDefined =}
|
|
5
|
+
import type { UserEmailSignupFields } from '../../providers'
|
|
6
|
+
{=/ isEmailUserSignupFieldsDefined =}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// PRIVATE API
|
|
9
|
+
export type EmailSignupData = {
|
|
9
10
|
email: string
|
|
10
11
|
password: string
|
|
11
|
-
}{=#
|
|
12
|
+
}{=# isEmailUserSignupFieldsDefined =} & UserEmailSignupFields{=/ isEmailUserSignupFieldsDefined =}
|
|
12
13
|
|
|
13
14
|
// PUBLIC API
|
|
14
15
|
export async function signup(data: EmailSignupData): Promise<{ success: boolean }> {
|
|
@@ -2,21 +2,24 @@
|
|
|
2
2
|
import { useState, useMemo } from 'react'
|
|
3
3
|
import { AuthContext, type ErrorMessage } from '@wasp.sh/lib-auth/browser'
|
|
4
4
|
import styles from './Auth.module.css'
|
|
5
|
-
import './internal/auth-styles.css'
|
|
6
|
-
import { tokenObjToCSSVars } from "./internal/util"
|
|
7
|
-
|
|
8
5
|
import {
|
|
9
|
-
|
|
6
|
+
FormMessageError as MessageError,
|
|
7
|
+
MessageSuccess,
|
|
8
|
+
tokenObjToCSSVars,
|
|
10
9
|
type CustomizationOptions,
|
|
11
10
|
type AdditionalSignupFields,
|
|
12
|
-
} from '
|
|
11
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
12
|
+
|
|
13
|
+
import type { State } from './types'
|
|
13
14
|
import { LoginSignupForm } from './internal/common/LoginSignupForm'
|
|
14
|
-
import { MessageError, MessageSuccess } from './internal/Message'
|
|
15
15
|
{=# isEmailAuthEnabled =}
|
|
16
16
|
import { ForgotPasswordForm } from './internal/email/ForgotPasswordForm'
|
|
17
17
|
import { ResetPasswordForm } from './internal/email/ResetPasswordForm'
|
|
18
18
|
import { VerifyEmailForm } from './internal/email/VerifyEmailForm'
|
|
19
19
|
{=/ isEmailAuthEnabled =}
|
|
20
|
+
{=# isDummyEmailSenderNoticeEnabled =}
|
|
21
|
+
import { DummyEmailSenderNotice } from './internal/email/DummyEmailSenderNotice'
|
|
22
|
+
{=/ isDummyEmailSenderNoticeEnabled =}
|
|
20
23
|
|
|
21
24
|
const logoStyle = {
|
|
22
25
|
height: '3rem'
|
|
@@ -57,6 +60,9 @@ function Auth ({ state, appearance, logo, socialLayout = 'horizontal', additiona
|
|
|
57
60
|
<h2 className={styles.headerText}>{title}</h2>
|
|
58
61
|
</div>
|
|
59
62
|
|
|
63
|
+
{=# isDummyEmailSenderNoticeEnabled =}
|
|
64
|
+
{(state === 'signup' || state === 'forgot-password') && <DummyEmailSenderNotice />}
|
|
65
|
+
{=/ isDummyEmailSenderNoticeEnabled =}
|
|
60
66
|
{errorMessage && (
|
|
61
67
|
<MessageError>
|
|
62
68
|
{errorMessage.title}{errorMessage.description && ': '}{errorMessage.description}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import Auth from './Auth'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from './types'
|
|
2
|
+
import type {
|
|
3
|
+
CustomizationOptions,
|
|
4
|
+
AdditionalSignupFields,
|
|
5
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
6
|
+
import { State } from './types'
|
|
7
7
|
|
|
8
8
|
// PUBLIC API
|
|
9
9
|
export function SignupForm({
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{{={= =}=}}
|
|
2
|
-
import { useForm, UseFormReturn } from 'react-hook-form'
|
|
2
|
+
import { useForm, type UseFormReturn } from 'react-hook-form'
|
|
3
3
|
import styles from './LoginSignupForm.module.css'
|
|
4
|
-
import '../auth-styles.css'
|
|
5
4
|
import { config } from '../../../../client/index.js'
|
|
6
|
-
import { clsx } from '../util'
|
|
7
|
-
|
|
8
|
-
import { useAuthContext } from '@wasp.sh/lib-auth/browser'
|
|
9
5
|
import {
|
|
6
|
+
clsx,
|
|
10
7
|
Form,
|
|
11
8
|
FormInput,
|
|
12
9
|
FormItemGroup,
|
|
@@ -14,19 +11,23 @@ import {
|
|
|
14
11
|
FormError,
|
|
15
12
|
FormTextarea,
|
|
16
13
|
SubmitButton,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from '
|
|
14
|
+
type AdditionalSignupFields,
|
|
15
|
+
type AdditionalSignupField,
|
|
16
|
+
type AdditionalSignupFieldRenderFn,
|
|
17
|
+
type FormState,
|
|
18
|
+
} from '@wasp.sh/lib-sdk-core/browser'
|
|
19
|
+
|
|
20
|
+
import { useAuthContext } from '@wasp.sh/lib-auth/browser'
|
|
21
|
+
{=# enabledProviders.isEmailAuthEnabled =}
|
|
22
|
+
import { emailFieldRules, emailInputProps } from '@wasp.sh/lib-sdk-core/browser'
|
|
23
|
+
{=/ enabledProviders.isEmailAuthEnabled =}
|
|
24
24
|
{=# isSocialAuthEnabled =}
|
|
25
|
-
import * as SocialIcons from '
|
|
26
|
-
import { SocialButton } from '
|
|
25
|
+
import * as SocialIcons from '@wasp.sh/lib-sdk-core/browser'
|
|
26
|
+
import { SocialButton } from '@wasp.sh/lib-sdk-core/browser'
|
|
27
27
|
{=/ isSocialAuthEnabled =}
|
|
28
28
|
{=# isAnyPasswordBasedAuthEnabled =}
|
|
29
29
|
import { useNavigate } from 'react-router'
|
|
30
|
+
import { getAuthErrorMessage } from '@wasp.sh/lib-sdk-core/browser'
|
|
30
31
|
{=/ isAnyPasswordBasedAuthEnabled =}
|
|
31
32
|
{=# enabledProviders.isUsernameAndPasswordAuthEnabled =}
|
|
32
33
|
import { useUsernameAndPassword } from '../usernameAndPassword/useUsernameAndPassword'
|
|
@@ -58,21 +59,18 @@ const gitHubSignInUrl = `${config.apiUrl}{= gitHubSignInPath =}`
|
|
|
58
59
|
const microsoftSignInUrl = `${config.apiUrl}{= microsoftSignInPath =}`
|
|
59
60
|
{=/ enabledProviders.isMicrosoftAuthEnabled =}
|
|
60
61
|
|
|
61
|
-
{
|
|
62
|
-
|
|
63
|
-
// know the exact shape of the form values. We are assuming that the form values
|
|
64
|
-
// will be a flat object with string values.
|
|
65
|
-
=}
|
|
66
|
-
// PRIVATE API
|
|
67
|
-
export type LoginSignupFormFields = {
|
|
68
|
-
[key: string]: string;
|
|
69
|
-
}
|
|
62
|
+
import type { LoginSignupFormFields } from '@wasp.sh/lib-sdk-core/browser'
|
|
63
|
+
|
|
70
64
|
|
|
71
65
|
// PRIVATE API
|
|
72
66
|
export const LoginSignupForm = ({
|
|
73
67
|
state,
|
|
68
|
+
{=# isSocialAuthEnabled =}
|
|
74
69
|
socialButtonsDirection = 'horizontal',
|
|
70
|
+
{=/ isSocialAuthEnabled =}
|
|
71
|
+
{=# isAnyPasswordBasedAuthEnabled =}
|
|
75
72
|
additionalSignupFields,
|
|
73
|
+
{=/ isAnyPasswordBasedAuthEnabled =}
|
|
76
74
|
}: {
|
|
77
75
|
state: 'login' | 'signup'
|
|
78
76
|
socialButtonsDirection?: 'horizontal' | 'vertical'
|
|
@@ -88,8 +86,8 @@ export const LoginSignupForm = ({
|
|
|
88
86
|
const cta = isLogin ? 'Log in' : 'Sign up';
|
|
89
87
|
{=# isAnyPasswordBasedAuthEnabled =}
|
|
90
88
|
const navigate = useNavigate();
|
|
91
|
-
const onErrorHandler = (error) => {
|
|
92
|
-
setErrorMessage(
|
|
89
|
+
const onErrorHandler = (error: unknown) => {
|
|
90
|
+
setErrorMessage(getAuthErrorMessage(error));
|
|
93
91
|
};
|
|
94
92
|
{=/ isAnyPasswordBasedAuthEnabled =}
|
|
95
93
|
const hookForm = useForm<LoginSignupFormFields>()
|
|
@@ -99,7 +97,7 @@ export const LoginSignupForm = ({
|
|
|
99
97
|
isLogin,
|
|
100
98
|
onError: onErrorHandler,
|
|
101
99
|
onSuccess() {
|
|
102
|
-
navigate(
|
|
100
|
+
navigate({=& onAuthSucceededRedirectTo =})
|
|
103
101
|
},
|
|
104
102
|
});
|
|
105
103
|
{=/ enabledProviders.isUsernameAndPasswordAuthEnabled =}
|
|
@@ -112,17 +110,22 @@ export const LoginSignupForm = ({
|
|
|
112
110
|
setSuccessMessage(`You've signed up successfully! Check your email for the confirmation link.`)
|
|
113
111
|
},
|
|
114
112
|
onLoginSuccess() {
|
|
115
|
-
navigate(
|
|
113
|
+
navigate({=& onAuthSucceededRedirectTo =})
|
|
116
114
|
},
|
|
117
115
|
});
|
|
118
116
|
{=/ enabledProviders.isEmailAuthEnabled =}
|
|
119
117
|
{=# isAnyPasswordBasedAuthEnabled =}
|
|
120
|
-
async function onSubmit
|
|
118
|
+
async function onSubmit(data: LoginSignupFormFields): Promise<void> {
|
|
121
119
|
setIsLoading(true);
|
|
122
120
|
setErrorMessage(null);
|
|
123
121
|
setSuccessMessage(null);
|
|
124
122
|
try {
|
|
125
|
-
|
|
123
|
+
// We assert the type because the form holds raw input strings, while the
|
|
124
|
+
// signup data type uses the return types of the user's signup field
|
|
125
|
+
// getters (e.g. `Promise<string>` for an async getter).
|
|
126
|
+
// TODO: Close the type gap between the forms and the user's signup fields,
|
|
127
|
+
// so this assertion can go away.
|
|
128
|
+
await handleSubmit(data as Parameters<typeof handleSubmit>[0]);
|
|
126
129
|
} finally {
|
|
127
130
|
setIsLoading(false);
|
|
128
131
|
}
|
|
@@ -189,10 +192,8 @@ export const LoginSignupForm = ({
|
|
|
189
192
|
<FormItemGroup>
|
|
190
193
|
<FormLabel>E-mail</FormLabel>
|
|
191
194
|
<FormInput
|
|
192
|
-
{...register('email',
|
|
193
|
-
|
|
194
|
-
})}
|
|
195
|
-
type="email"
|
|
195
|
+
{...register('email', emailFieldRules)}
|
|
196
|
+
{...emailInputProps}
|
|
196
197
|
disabled={isLoading}
|
|
197
198
|
/>
|
|
198
199
|
{errors.email && <FormError>{errors.email.message}</FormError>}
|
package/data/Generator/templates/sdk/wasp/auth/forms/internal/email/DummyEmailSenderNotice.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import styles from "./DummyEmailSenderNotice.module.css";
|
|
2
|
+
|
|
3
|
+
// PRIVATE API
|
|
4
|
+
/**
|
|
5
|
+
* Tells developers where to find the emails, since the Dummy email sender
|
|
6
|
+
* prints them in the terminal instead of sending them.
|
|
7
|
+
*/
|
|
8
|
+
export function DummyEmailSenderNotice() {
|
|
9
|
+
return (
|
|
10
|
+
<div className={styles.notice}>
|
|
11
|
+
<p>You are using the Dummy email sender.</p>
|
|
12
|
+
<p>
|
|
13
|
+
To see sent emails, check the <code>wasp start</code> terminal.
|
|
14
|
+
</p>
|
|
15
|
+
</div>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { useForm } from 'react-hook-form'
|
|
2
1
|
import { useAuthContext } from '@wasp.sh/lib-auth/browser'
|
|
2
|
+
import { useForm } from 'react-hook-form'
|
|
3
3
|
|
|
4
4
|
import { requestPasswordReset } from '../../../email/actions/passwordReset.js'
|
|
5
|
-
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError } from '
|
|
5
|
+
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError, emailFieldRules, emailInputProps, getAuthErrorMessage } from '@wasp.sh/lib-sdk-core/browser'
|
|
6
6
|
|
|
7
|
+
type ForgotPasswordFormFields = { email: string };
|
|
7
8
|
|
|
8
9
|
// PRIVATE API
|
|
9
10
|
export const ForgotPasswordForm = () => {
|
|
10
|
-
const { register, handleSubmit, reset, formState: { errors } } = useForm<
|
|
11
|
+
const { register, handleSubmit, reset, formState: { errors } } = useForm<ForgotPasswordFormFields>()
|
|
11
12
|
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext()
|
|
12
13
|
|
|
13
|
-
const onSubmit = async (data) => {
|
|
14
|
+
const onSubmit = async (data: ForgotPasswordFormFields): Promise<void> => {
|
|
14
15
|
setIsLoading(true)
|
|
15
16
|
setErrorMessage(null)
|
|
16
17
|
setSuccessMessage(null)
|
|
@@ -18,11 +19,8 @@ export const ForgotPasswordForm = () => {
|
|
|
18
19
|
await requestPasswordReset(data)
|
|
19
20
|
reset()
|
|
20
21
|
setSuccessMessage('Check your email for a password reset link.')
|
|
21
|
-
} catch (error) {
|
|
22
|
-
setErrorMessage(
|
|
23
|
-
title: error.message,
|
|
24
|
-
description: error.data?.data?.message,
|
|
25
|
-
})
|
|
22
|
+
} catch (error: unknown) {
|
|
23
|
+
setErrorMessage(getAuthErrorMessage(error));
|
|
26
24
|
} finally {
|
|
27
25
|
setIsLoading(false)
|
|
28
26
|
}
|
|
@@ -34,10 +32,8 @@ export const ForgotPasswordForm = () => {
|
|
|
34
32
|
<FormItemGroup>
|
|
35
33
|
<FormLabel>E-mail</FormLabel>
|
|
36
34
|
<FormInput
|
|
37
|
-
{...register('email',
|
|
38
|
-
|
|
39
|
-
})}
|
|
40
|
-
type="email"
|
|
35
|
+
{...register('email', emailFieldRules)}
|
|
36
|
+
{...emailInputProps}
|
|
41
37
|
disabled={isLoading}
|
|
42
38
|
/>
|
|
43
39
|
{errors.email && <FormError>{errors.email.message}</FormError>}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
+
import { useAuthContext } from '@wasp.sh/lib-auth/browser'
|
|
1
2
|
import { useForm } from 'react-hook-form'
|
|
2
3
|
import { useLocation } from 'react-router'
|
|
3
|
-
import { useAuthContext } from '@wasp.sh/lib-auth/browser'
|
|
4
4
|
|
|
5
5
|
import { resetPassword } from '../../../email/actions/passwordReset.js'
|
|
6
|
-
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError } from '
|
|
6
|
+
import { Form, FormItemGroup, FormLabel, FormInput, SubmitButton, FormError, getAuthErrorMessage } from '@wasp.sh/lib-sdk-core/browser'
|
|
7
|
+
|
|
8
|
+
type ResetPasswordFormFields = { password: string; passwordConfirmation: string };
|
|
7
9
|
|
|
8
10
|
// PRIVATE API
|
|
9
11
|
export const ResetPasswordForm = () => {
|
|
10
|
-
const { register, handleSubmit, reset, formState: { errors } } = useForm<
|
|
12
|
+
const { register, handleSubmit, reset, formState: { errors } } = useForm<ResetPasswordFormFields>()
|
|
11
13
|
const { isLoading, setErrorMessage, setSuccessMessage, setIsLoading } = useAuthContext()
|
|
12
14
|
const location = useLocation()
|
|
13
15
|
const token = new URLSearchParams(location.search).get('token')
|
|
14
|
-
const onSubmit = async (data) => {
|
|
16
|
+
const onSubmit = async (data: ResetPasswordFormFields): Promise<void> => {
|
|
15
17
|
if (!token) {
|
|
16
18
|
setErrorMessage({
|
|
17
19
|
title:
|
|
@@ -32,11 +34,8 @@ export const ResetPasswordForm = () => {
|
|
|
32
34
|
await resetPassword({ password: data.password, token })
|
|
33
35
|
reset()
|
|
34
36
|
setSuccessMessage('Your password has been reset.')
|
|
35
|
-
} catch (error) {
|
|
36
|
-
setErrorMessage(
|
|
37
|
-
title: error.message,
|
|
38
|
-
description: error.data?.data?.message,
|
|
39
|
-
})
|
|
37
|
+
} catch (error: unknown) {
|
|
38
|
+
setErrorMessage(getAuthErrorMessage(error));
|
|
40
39
|
} finally {
|
|
41
40
|
setIsLoading(false)
|
|
42
41
|
}
|