ronzeidman / ng2-ui-auth

an angular2 repository for authentication based on angular1's satellizer
MIT License
206 stars 64 forks source link

Change config dynamically #129

Open mcblum opened 6 years ago

mcblum commented 6 years ago

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

ronzeidman commented 6 years ago

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

mcblum commented 6 years ago

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.

ronzeidman commented 6 years ago

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.

mcblum commented 6 years ago

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.

ronzeidman commented 6 years ago

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

ronzeidman commented 6 years ago

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

MrLuis1 commented 6 months ago

@ronzeidman Does the updateProviders method still exist in version 10.0.1 of the library? I need to do something similar with Shopify and I can't find any method or way to update the authorizationEndpoint dynamically with the Shopify store domain.