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

Delayed initialization #70

Closed
Pajk opened this Issue Feb 24, 2017 · 4 comments

Comments

Projects
None yet
3 participants
@Pajk

Pajk commented Feb 24, 2017

I would like to initialize firebase after user logs in in our app. In the old version of our app we use custom authentication and authenticated user can fetch firebase config from our api (apiKey, databaseUrl, authDomain) so we don't have to hardcode it in the frontend app.

Is there a way how to achieve this? I checked the source code and it looks that fbConfig is required in reactReduxFirebase and I didn't find a way how to set config values dynamically.

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Feb 24, 2017

Owner

Injecting a reducer using an injectReducer function (common pattern with async loading of routes) is probably possible:

export const injectReducer = (store, { key, reducer }) => {
  store.asyncReducers[key] = reducer; // eslint-disable-line no-param-reassign
  store.replaceReducer(makeRootReducer(store.asyncReducers));
};

Not sure if this pattern would be usable for injecting the reducer, but there is still the issue of adding the middleware. I will have to do some more research to look into the possibility of supporting delayed initialization.

Is there a reason to not hardcode the info on the client? Is it due to wanting to point to different Firebase instances in different environments? If so, I could potentially be of some help on that front since I have experience setting up and running quite a few multi-environment setups in production that each point to different Firebase instances.

Owner

prescottprue commented Feb 24, 2017

Injecting a reducer using an injectReducer function (common pattern with async loading of routes) is probably possible:

export const injectReducer = (store, { key, reducer }) => {
  store.asyncReducers[key] = reducer; // eslint-disable-line no-param-reassign
  store.replaceReducer(makeRootReducer(store.asyncReducers));
};

Not sure if this pattern would be usable for injecting the reducer, but there is still the issue of adding the middleware. I will have to do some more research to look into the possibility of supporting delayed initialization.

Is there a reason to not hardcode the info on the client? Is it due to wanting to point to different Firebase instances in different environments? If so, I could potentially be of some help on that front since I have experience setting up and running quite a few multi-environment setups in production that each point to different Firebase instances.

@prescottprue prescottprue self-assigned this Feb 24, 2017

@Pajk

This comment has been minimized.

Show comment
Hide comment
@Pajk

Pajk Feb 25, 2017

Pajk commented Feb 25, 2017

@prescottprue

This comment has been minimized.

Show comment
Hide comment
@prescottprue

prescottprue Feb 25, 2017

Owner

Your Firebase config should be ok to have exposed since it is for a client to authenticate to begin with. Beyond that, you can have roles or an approved: true parameter on your user profiles to limit user access to your whole application or just parts of it.

I might be a little more help over gitter so I can get a better understanding of what you are going for.

Owner

prescottprue commented Feb 25, 2017

Your Firebase config should be ok to have exposed since it is for a client to authenticate to begin with. Beyond that, you can have roles or an approved: true parameter on your user profiles to limit user access to your whole application or just parts of it.

I might be a little more help over gitter so I can get a better understanding of what you are going for.

@pahen

This comment has been minimized.

Show comment
Hide comment
@pahen

pahen Apr 3, 2018

How did you solve this? I have the same problem ..

pahen commented Apr 3, 2018

How did you solve this? I have the same problem ..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment