Next.js Discord

Discord Forum

Firebase email/password login,

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Cannot find any examples of implementing this logic properly in NextAuth.
  providers: [
    GoogleProvider({
      clientId: config.google.clientId,
      clientSecret: config.google.clientSecret,
    }),
    CredentialsProvider({
      name: "Credentials",
      credentials: {
        email: {
          label: "Email",
          type: "text",
          placeholder: "jsmith@example.com",
        },
        password: { label: "Password", type: "password" },
      },
      async authorize(credentials) {
        if (!credentials) return null;

        // sanitize credentials
        credentials.email = credentials.email.trim().toLowerCase();
        credentials.password = credentials.password.trim();

        const userCredential = await signInWithEmailAndPassword(
          auth,
          credentials.email,
          credentials.password
        );
        
        const user = userCredential.user;

        if (!user) return null;

        return {
          id: user.uid,
          email: user.email,
        };
      },
    }),
    // ...add more providers here
  ],

these are my providers, the google provider works perfectly, however I am having trouble setting up the email/password firebase method. Any ideas on what could be wrong here?

1 Reply

Blue-headed Vireo
Did you happen to be able to solve it? Because I'm facing basically the same problem and I can't solve it...