Hi there wanted some help with migration of passwords.

A little bit of background, so far using self setup auth (this didnt exist back when i started or hell na would never go for setting everything up myself), now the problem is the password for users there were salted and hashed using bcrypt, now that i have finally decided to move to better-auth, have completed basic setup the issue is there are 5000+ users, and im very confused how do i go about the passwords,:

  1. Send a password resend email to all users which should reflect on the account table (better-auth). Not a fan of this approach and would like to keep it as my final option
  2. Logically makes sense go for gradual migration where users keep logging in via their current email and password using the old api and if the login is valid update the account table corresponding to the user with the password as well. (The issue im seeing here is i fully dont understand how i can do this directly, im not sure how to go about the hashing for the password updating the db is straightforward)
  3. Is there a way where i can update the password comapre method? (Sorry been at it for days and am all over the place if i missed something in the docs)
gradually plan is to add more plugins but started with basic and will add oauth if i can get the basics working.

I verified on my account by resetting the password that it works fine thats where my assumption of the hash difference came.

Please feel free to ask any more questions if that might help, and thank you for your help.
Solution
i didnt realize it sooner but better-auth/crypto exposes hashPassword function i have temporarily held off and will wait for a week or two till users login enough and i can have their password migrated.

TLDR:

Using the existing login to be demised in 2weeks or so, if login is success (email, password match) -> use hashPassword from better-auth/crypto to hashPassword and update account if it exists with the proper hashed password.

import {hashPassword} from "better-auth/crypto";

public updateBetterAuthPassword = async (userId: number, email: string, password: string) => {
    const account = await this.getOrCreateAccount(userId, email);
    if(account === false) return;
    account.password = await hashPassword(password);
    return await this.Account.save(account);

  }
Was this page helpful?