Skip to content

Users are redirected to the dashboard regardless of sign-up success on branch step/1 #8

@keplib

Description

@keplib

Hi,

I'm quite new to Next.js, so this might just be a question rather than an issue. However, I have some doubts about the implementation of the user registration in actions/auth.ts:

Screenshot 2024-12-30 at 19 48 29

From what I understand, it seems like users are redirected to the dashboard regardless of whether the sign-up was successful. I think this behavior might not be ideal, as it could result in users being redirected even if there was an error during registration.

My proposed solution would be:

  • Return {success: true} in the try block and {success: false} in the catch block to clearly indicate the outcome of the action.
Screenshot 2024-12-30 at 19 50 49
  • On the client side (in SignupForm.tsx), use useEffect and useRouter to redirect users to the dashboard only when the action response indicates success.
Screenshot 2024-12-30 at 19 49 32

I realize that this might be addressed later in the course, but I wanted to share my thoughts in case this is an oversight. If this is indeed acknowledged as an issue, what would the next steps be for fixing it?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions