Change acr_values on already instantiated UserManager
I want to enable some "account switching" functionality in our app based on the acr_values property. I'm wondering if there's a way to change the acr_values in an already instantiated UserManager, and then have the auth silent redirect kick in with the update acr_values.
Is this something supported by the library? Am I thinking about this wrong?
You should be able to pass it to the various signin APIs.
Okay, I think I'm seeing that I can modify the acr_values on my options object and then call manager.signinSilent(myOptions). I've modified it and set prompt: 'none' but I'm getting an error:
Uncaught (in promise) Error: Frame window timed out
at IFrameWindow._error (oidc-client.min.js:3)
at IFrameWindow._timeout (oidc-client.min.js:3)
Actually, it looks like it is doing the redirect and getting the new sub, however it gives me a timeout afterwards.
I have this code:
switchAccount(accountId) {
console.log(`Switching to account ${accountId}`);
this.options.acr_values = `tenant:${accountId}`;
this.options.prompt = 'none';
this.manager.signinSilent(this.options).then((user) => {
window.location.reload();
});
}
The request log looks like:
Switching to account 473980152
UserManager.getUser: user loaded
UserManager.getUser: user loaded
UserManager.signinRedirectCallback: successful, signed in sub: 974500581774742877
UserManager.getUser: user loaded
oidc-client.min.js:1 Frame window timed out
oidc-client.min.js:3 Uncaught (in promise) Error: Frame window timed out
at IFrameWindow._error (oidc-client.min.js:3)
at IFrameWindow._timeout (oidc-client.min.js:3)
The page doesn't refresh. (In the end i'm not looking to do a full page refresh. I just need to do it right now before refactoring some other things to fire off when the account is changed up)
Any update?
Ended up going with this code instead for now to achieve what I wanted:
this.options.acr_values = `tenant:${accountId}`;
this.options.prompt = 'login';
this.manager.removeUser();
this.manager.signinRedirect(this.options);
Thanks for the feedback!