Where to place code to set Firebase auth state persistence in Vue.js?

前端 未结 1 530
感情败类
感情败类 2021-01-14 06:08

Overview

I\'m building a web app in Quasar/Vue.js and Firebase which needs to authenticate users.

What I\'m trying to achieve

A pretty common fea

相关标签:
1条回答
  • 2021-01-14 06:41

    I'd do it wherever you have firebase.initializeApp(). Eg

    firebase.initializeApp({
      // config goes here
    });
    
    export const auth = firebase.auth()
    
    auth.setPersistence(firebase.auth.Auth.Persistence.LOCAL)
    

    Note that LOCAL is the default in web apps already.

    You don't really need to wait for that promise. From the docs

    This will return a promise that will resolve once the state finishes copying from one type of storage to the other. Calling a sign-in method after changing persistence will wait for that persistence change to complete before applying it on the new Auth state.

    0 讨论(0)
提交回复
热议问题