2 months ago
Hey there,
When I set up my instance, I used my password generator to create the password and unfortunately I lost it. Is there any way to recover my account?
Forgot password email doesn't work because I never set up SMTP.
Pinned Solution
a month ago
There’s no supported way to generate a compatible hash without using Better Auth itself.
If the secret is lost, then spinning up a new instance is unfortunately the only option.
7 Replies
2 months ago
Hey, if you have direct access to your server/container where the instance is running, you can reset the password directly through the database or command line.
a month ago
Template maintainer here, I'd try what the above post recommended, I'm don't know any other way personally
Status changed to Awaiting User Response Railway • about 2 months ago
a month ago
Thanks for the replies! Given that the passwords are hashed and encryption is done with BETTER_AUTH_SECRET variable, do either of you know how I would do this?
I already connected to my database and was able to view the hash, but I have no idea how to generate a password that would be recognized by the auth.
I could always just spin up a new template, but I figured I'd try this first to retain the data. I still can't believe that I failed to save the password haha.
Status changed to Awaiting Template Creator Response Railway • about 2 months ago
landynu
Thanks for the replies! Given that the passwords are hashed and encryption is done with BETTER_AUTH_SECRET variable, do either of you know how I would do this?I already connected to my database and was able to view the hash, but I have no idea how to generate a password that would be recognized by the auth.I could always just spin up a new template, but I figured I'd try this first to retain the data. I still can't believe that I failed to save the password haha.
a month ago
You won’t be able to “recover” the original password since it’s a one-way hash, but you can reset it as long as you still have the same BETTER_AUTH_SECRET.
Because Better Auth derives the password hash using that secret, the only way to generate a valid replacement is to rehash a new password using Better Auth’s own hashing function, not by manually editing the hash.
a month ago
There’s no supported way to generate a compatible hash without using Better Auth itself.
If the secret is lost, then spinning up a new instance is unfortunately the only option.
a month ago
Thanks all, I was able to get it to work! I was mistaken that I needed the BETTER_AUTH_SECRET
I downloaded a copy of the repository and ran the following in my IDE and then pasted in the password field right in Railway. I am sure there is a better way, but if anyone else loses their password, this worked!
cd "{{project_directory}}" && node -e "
import('better-auth/crypto').then(async (crypto) => {
const hash = await crypto.hashPassword('{{new_password}}');
console.log(hash);
});
"
a month ago
Glad I helped you
Status changed to Open Railway • about 2 months ago
Status changed to Solved dev • about 2 months ago