blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Bug forgot password

Open Wykaz opened this issue 3 years ago • 1 comments

What is the problem?

On a new project, the forgotten password option does not work.

Paste all your error logs here:

wait  - compiling /auth/forgot-password (client and server)...
event - compiled client and server successfully in 614 ms (299 modules)
Warning: Received `true` for a non-boolean attribute `global`.

If you want to write it to the DOM, pass a string instead: global="true" or global={value.toString()}.
    at style
    at form
    at ReactFinalForm
    at Form
    at Layout
    at ForgotPasswordPage
    at BlitzAuthInnerRoot
    at ErrorBoundary
    at MyApp
    at Hydrate
    at QueryClientProvider
    at BlitzProvider
    at BlitzOuterRoot
    at WithSuperJSON
    at StyleRegistry
    at AppContainer
    at AppContainerWithIsomorphicFiberStructure
    at div
    at Body
Warning: Received `true` for a non-boolean attribute `jsx`.

If you want to write it to the DOM, pass a string instead: jsx="true" or jsx={value.toString()}.
    at style
    at form
    at ReactFinalForm
    at Form
    at Layout
    at ForgotPasswordPage
    at BlitzAuthInnerRoot
    at ErrorBoundary
    at MyApp
    at Hydrate
    at QueryClientProvider
    at BlitzProvider
    at BlitzOuterRoot
    at WithSuperJSON
    at StyleRegistry
    at AppContainer
    at AppContainerWithIsomorphicFiberStructure
    at div
    at Body
wait  - compiling /api/rpc/[[...blitz]]...
event - compiled successfully in 362 ms (138 modules)
21:57:39.470 INFO  /forgotPassword() Starting with input: 
{
  email: '[email protected]'
}
21:57:41.933 INFO  /forgotPassword() Finished: resolver:2.4s serializer:9ms total:2.5s 
error - uncaughtException: Error: spawn undefined\System32\WindowsPowerShell\v1.0\powershell ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
  path: 'undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',
  spawnargs: [
    '-NoProfile',
    '-NonInteractive',
    '–ExecutionPolicy',
    'Bypass',
    '-EncodedCommand',
    'UwB0AGEAcgB0ACAAIgBmAGkAbABlADoALwAvAEMAOgBcAFUAcwBlAHIAcwBcAFQAaABvAG0AYQBzAFwAQQBwAHAARABhAHQAYQBcAEwAbwBjAGEAbABcAFQAZQBtAHAALwA2AGMAMQBlADYAZgA2ADkALQBiAGUAZgBlAC0ANAAxAGUAMwAtADgANgAwADMALQAxADYANwAxADIAZABhADgAYgBmADkANgA
uAGgAdABtAGwAIgA='
  ]
}

Paste all relevant code snippets here:

I think it comes from here

mailers/forgetPasswordMailer.js

// Preview email in the browser
        const previewEmail = (await import("preview-email")).default
        await previewEmail(msg)

What are detailed steps to reproduce this?

  1. npm install -g blitz
  2. blitz new blitzjs-test
  3. cd blitzjs-test
  4. blitz dev
  5. View your brand new app at http://localhost:3000/
  6. Create an account.
  7. Click on "Logout".
  8. Go to the login page.
  9. Click on "Forgot your password?".
  10. A console error

Run blitz -v and paste the output here:

Blitz version: 2.0.0-beta.3 (global)
Blitz version: 2.0.0-beta.3 (local)
Windows 10 | win32-x64 | Node: v16.17.0


 Package manager: npm

  System:
    OS: Windows 10 10.0.19044
    CPU: (4) x64 Intel(R) Core(TM) i5-3340 CPU @ 3.10GHz
    Memory: 4.18 GB / 15.95 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.19.2 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.3 => 2.0.0-beta.3
    @blitzjs/next: 2.0.0-beta.3 => 2.0.0-beta.3
    @blitzjs/rpc: 2.0.0-beta.3 => 2.0.0-beta.3
    @prisma/client: 4.0.0 => 4.0.0
    blitz: 2.0.0-beta.3 => 2.0.0-beta.3
    next: 12.2.5 => 12.2.5
    prisma: 4.0.0 => 4.0.0
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: ^4.5.3 => 4.8.3

Please include below any other applicable logs and screenshots that show your problem:

No response

Wykaz avatar Sep 19 '22 20:09 Wykaz

I just tested on osx and it's working. By the looks of your error this may be a window specific issue.

itsdillon avatar Sep 20 '22 17:09 itsdillon

@Wykaz can you check if you something else set to open .html files in windows settings? If you don't have anything set it prompts you. If you have it set to something else change it to your default browser

image

image

Zeko369 avatar Sep 30 '22 18:09 Zeko369

I have a browser configured for you to open .html but it does not work. image

Wykaz avatar Oct 02 '22 22:10 Wykaz

@Wykaz there could be a problem with where it stores the files, try changing await previewEmail() to this and create a tmp folder in the root of your project

await previewEmail(msg, { open: true, dir: join(process.cwd(), "./tmp") })

Zeko369 avatar Oct 03 '22 11:10 Zeko369

Thank you for taking the time to resolve the issue. It was this import?

import { join } from "path"

I tried with it and it doesn't work, it gives the same error.

Wykaz avatar Oct 03 '22 22:10 Wykaz

@Wykaz I think the problem lies with previewEmail not being able to read your process.env.SYSTEMROOT environment variable to launch PowerShell

path: 'undefined\\System32\\WindowsPowerShell\\v1.0\\powershell',

The path to PowerShell should have been "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell"

Can you check if the problem resolves if you manually set the systemroot in your project's .env file as

SYSTEMROOT = C:\\WINDOWS

or the output that you get when executing

image

siddhsuresh avatar Oct 04 '22 03:10 siddhsuresh

I added dfgdfg in the .env file and it works. Thanks

But when I do this to modify the .env file the variable was good image

Wykaz avatar Oct 04 '22 17:10 Wykaz

May I know why

SYSTEMROOT="C:\WINDOWS"

is not working if i put it only inside .env.local but it is working if i put it only inside .env?

adamtang79 avatar Oct 11 '22 04:10 adamtang79