username plugin: password.verify not being called?

import { betterAuth } from 'better-auth'
import { genericOAuth, username } from 'better-auth/plugins'
import { nextCookies } from "better-auth/next-js";

// Database adapter
import { prismaAdapter } from "better-auth/adapters/prisma";
import { PrismaService } from '@/core/services/server/prisma'
import { hashPass, isSamePass, isSamePassword } from '@/core/utils/auth'

export const auth = betterAuth({
  database: prismaAdapter(PrismaService, {
    provider: 'sqlite',
  }),
  user: {
    additionalFields: {
      // ...
    },
  },
  emailAndPassword: {
    enabled: true,
    password: {
      hash: hashPass,
      verify: (data) => {
        console.error("NOT PRINTING")
        return isSamePass(data.password, data.hash)
      },
    },
  },
  socialProviders: {
    google: {
      // ...
    },
  },
  plugins: [
    genericOAuth({
      config: [
        // ....
      ],
    }),
    username(),
    nextCookies(),
  ],
})

export type Session = typeof auth.$Infer.Session


This is my code. When doing a POST request to http://localhost:3000/api/auth/sign-in/username

with: {username:"teste",password:"teste123",rememberMe:true}

It returns: {"code":"INVALID_USERNAME_OR_PASSWORD","message":"Invalid username or password"}

signIn.username(
      {...credentials, rememberMe: true },
// ...
);


And the hash function is never called. (No print occurs in the logs). 401 is thrown. I am using bcrypt that's why I replaced the verify and hash function.
Solution
The issue was with providerId in next-auth being credentials and not credential
Was this page helpful?