Search code examples
node.jsfirebasefirebase-authenticationfirebase-admin

Change language of URL on generateEmailVerificationLink() FirebaseAdmin SDK


I want to change the language of the link that was generating the function generateEmailVerificationLink (), I tried admin.auth().LanguageCode = 'es', but it didn't work.

This is my code:

  // Function for creating to validation link with firebase admin
async getLinkForEmailVerification(email) {
    admin.auth().languageCode= 'es';
    const actionCodeSettings = {
        url: 'http://localhost:4200/login',
    };

    return admin.auth().generateEmailVerificationLink(email, actionCodeSettings).then((link) => link);
}

I'm using firebase admin with node.js


Solution

  • Custom it by manually way - Appending lang parameter to the link:

    async getLinkForEmailVerification(email) {
      const actionCodeSettings = {
        url: 'http://localhost:4200/login',
      };
    
      let link = await admin.auth().generateEmailVerificationLink(email, actionCodeSettings);
      link += '&lang=es'; // this line
    
      return link;
    }