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

loadUserProfile() no longer typesafe #1144

Open
freis-hdi opened this issue Oct 5, 2021 · 3 comments
Open

loadUserProfile() no longer typesafe #1144

freis-hdi opened this issue Oct 5, 2021 · 3 comments
Labels
docs Issues that involve improving or adding documentation.

Comments

@freis-hdi
Copy link

I just upgraded to version 12 and face an issue with loading the userinfo.

After PR #939 the return type of loadUserProfile() changed from Userinfo to Userinfo | string and now to object.

I thought, I could still at least cast to Userinfo, but weirdly the response is wrapped like this:

{
  "info": {
    "sub": "...",
    "name": "...",
    ...
  }
}

instead of

{
  "sub": "...",
  "name": "...",
  ...
}

so that I would have to call

private userinfoSubject$ = new ReplaySubject<UserInfo>();

...

  this.oauthService.loadUserProfile().then(userinfo => {
    // tslint:disable-next-line
    this.userinfoSubject$.next(userinfo['info'] as UserInfo);
    ...
  }

I would really like to find a cleaner solution to this.

Is the response wrapped in "info" on purpose?
And why did the response type change from Userinfo | string to object?

@jeroenheijmans jeroenheijmans added investigation-needed Indication that the maintainer or involved community members may need to investigate more. question For tagging support requests and general questions. labels Oct 5, 2021
@jeroenheijmans
Copy link
Collaborator

That's a good question indeed! I do not have the answer. I did trace it to the changes (amongst others) here:

bbff95b#diff-685e26c24f3c008856834f8b4a350d5472b6aea01a623c31a8513f6cc599c57fL722-R722

In that PR I also see an open comment (from after the commits were made I think) saying something similar.

@freis-hdi
Copy link
Author

@jeroenheijmans Yes, i traced it back to that too and was relieved that I wasn't the only one having problems with this change.

GregoireLgt referenced this issue Feb 4, 2022
…t opens multiple popup instead of focusing already opened
@jeroenheijmans
Copy link
Collaborator

We actually ran into this when upgrading the library in one of our applications.

At this point it's probably not useful to revert this breaking change anymore. However, I think it would be good to have the README and relevant release notes mention that the data from loadUserProfile's lambda now needs to be changed to do the .info step to get to the actual data:

      return this.oAuthService.loadUserProfile()
        .then((userProfile: Record<string, unknown>) => {
          const user = new User(userProfile?.info);

@jeroenheijmans jeroenheijmans added docs Issues that involve improving or adding documentation. and removed question For tagging support requests and general questions. investigation-needed Indication that the maintainer or involved community members may need to investigate more. labels Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues that involve improving or adding documentation.
Projects
None yet
Development

No branches or pull requests

2 participants