ng2-ui-auth icon indicating copy to clipboard operation
ng2-ui-auth copied to clipboard

Change config dynamically

Open mcblum opened this issue 6 years ago • 7 comments

Hello. Thanks for making this package. I have a situation where I need to change the config because different companies can have different providers. Is there any way to set the config after the app has been bootstrapped?

Thank you! Matt

mcblum avatar Dec 06 '17 03:12 mcblum

You can bootstrap a few similar new providers instead of extending the built-in ones and choosing which config you want at runtime

ronzeidman avatar Dec 06 '17 08:12 ronzeidman

Sorry that I'm being dense, but how do I actually bootstrap the providers at runtime? All of the syntax examples basically have you pass in a config.

mcblum avatar Dec 06 '17 16:12 mcblum

You'll have to pass to the config at bootstrap time and then at runtime you choose which one you want using its name. I could probably add the ability to pass the full provider at runtime instead of just the name, it may even be better in terms of tree shaking (if I make it mandatory), but in the meantime, this is the only option. You could create a fork and add this ability (shouldn't be very hard) and I'll appreciate it if you create a pull request afterward.

ronzeidman avatar Dec 07 '17 10:12 ronzeidman

I'll give it a shot and see if I can figure it out. The use case for this is that within our app you can't know in advance of loading the app which providers will be available. The reason for that is that one site serves multiple different companies and basically pulls their logo and other information. If we could make our API call, get the data and then bootstrap the providers that would be amazing. Basically expose a addProvider() method and updateProvider() for changes at runtime.

Going to fork and give it a try but I'm a bit out of my depths when it comes to developing packages like this. Probably as good a time as any to learn, though.

mcblum avatar Dec 07 '17 15:12 mcblum

Good luck! If you have any questions you are welcome to ask.

ronzeidman avatar Dec 10 '17 09:12 ronzeidman

in the new beta for angular 6 I've added updateProviders function. You can try it.

ronzeidman avatar May 09 '18 10:05 ronzeidman