I have seen how to set the password reset language in the browser (firebase/auth
) with useDeviceLanguage()
, however I have not seen how to create the password reset link with firebase-admin
The code with firebase-admin
to reset the password is below, but how can you change the language to, say, Spanish? The templates exist already in firebase.
const getPasswordResetLink = async email => {
// HOW TO CHANGE LANGUAGE?
return admin.auth().generatePasswordResetLink(email)
}
Solution: The link generates a lang
property in the query string, you can manually change this after you get the link to say lang=es
.
const getPasswordResetLink = async (email, languageSymbol) => {
const link = await admin.auth().generatePasswordResetLink(email)
const url = new URL(link)
if (languageSymbol) {
url.searchParams.set('lang', languageSymbol)
}
return url.toString()
}
As for the second argument in generatePasswordResetLink()
, it doesn't appear there are any useful options to have this set from firebase, you need to do the solution above. Here is the second argument options for reference https://github.com/firebase/firebase-admin-node/blob/bf4bacb18dc2e500a54ae7aa93b2db334c6ad4db/src/auth/index.ts#L947