Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using auth.onAuthStateChanged() in default export #545

Open
mewcrazy opened this issue Dec 31, 2019 · 3 comments
Open

Using auth.onAuthStateChanged() in default export #545

mewcrazy opened this issue Dec 31, 2019 · 3 comments

Comments

@mewcrazy
Copy link

@mewcrazy mewcrazy commented Dec 31, 2019

Hello,

I'm trying to delay the execution of my App until Firebase receives the Auth status before my "not logged in"-redirections take place. Afaik this is usually done with:

auth.onAuthStateChanged((user) => {
new Vue()
})

But in my current Vue setup my Vue instance get called in a total different way, which gives me a tough time.

// we should return factory for SSR (runInNewContext: false) export default context => { const store = createStore(context), router = createRouter(context); sync(store, router); return new Vue({ i18n, store, router, ...app }); };

I tried encapsulating new Vue to a const, and turn this constant inside the onAuthStateChanged function. Didn't work. Inside the export default neither. Around the return new Vue neither.

Can someone give me a hint? I already killed hours on this simple task :/

P.S. I'm working with SSR.

@posva
Copy link
Member

@posva posva commented Dec 31, 2019

This is not related to Vuefire, but I'm interested in adding it to the cookbook if anybody did Firebase authentication + SSR

@mewcrazy
Copy link
Author

@mewcrazy mewcrazy commented Dec 31, 2019

If needed I can deliver some source files. My SSR setup seems pretty complex.

@hacknug
Copy link
Contributor

@hacknug hacknug commented Jan 20, 2020

This article was quite helpful when I was implementing this earlier: https://dev.to/gautemeekolsen/vue-guard-routes-with-firebase-authentication-f4l

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.