Skip to content

Failed login, code is broken and will break. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Redbeardjunior opened this issue Sep 21, 2024 · 2 comments
Open

Failed login, code is broken and will break. #3

Redbeardjunior opened this issue Sep 21, 2024 · 2 comments

Comments

@Redbeardjunior
Copy link

image

server will break after putting in an wrong password.

@Nemathullahkhan
Copy link

I'm also facing the same issue.. If you've resolved it please do let me know

@tanjunior
Copy link

tanjunior commented Feb 16, 2025

you have to wrap the sigin in another function

"use server";
export async function mySignIn(
  provider: string,
  credentials?: z.infer<typeof userLoginForm>,
) {
  try {
    if (provider == "credentials") {
      await signIn(provider, { ...credentials, redirect: false});
    } else await naSignIn(provider, { redirect: false });
  } catch (error) {
    if (isRedirectError(error)) {
      return error.message;
    } else if (error instanceof CredentialsSignin) {
      return error.cause;
    } else if (error instanceof ZodError) {
      return error.message;
    } else if (error instanceof Error) {
      console.log(error);
      return error.message;
    } else if (typeof error === "string") {
      return error;
    } else {
      return "something went wrong";
    }
  }
  redirect("/")
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants