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

Returning accounts go first in getUserInfo #483

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1635,23 +1635,27 @@ When invoking the {{IdentityProvider/getUserInfo()}} method given an {{IdentityP
{{DOMException}}.
1. Let |accountsList| be the result of [=fetch the accounts list=] with |config|, |provider|,
and |globalObject|.
1. Let |hasReturningAccount| be false.
1. For each |account| in |accountsList|:
1. Let |isReturningAccount| be a new [=list=] of the same length as |accountsList|, with all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be on the accounts, rather than adding a new boolean?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The accounts are dictionaries parsed from the IdP's response, so we cannot add properties to them.

values initially set to false.
1. For each |i| from 0 to the length of |accountsList| minus 1:
1. Let |account| be |accountsList|[|i|].
1. If |account|["{{IdentityProviderAccount/approved_clients}}"] is not empty and it does not
[=list/contain=] |provider|'s {{IdentityProviderConfig/clientId}}, continue.

Note: this allows the [=IDP=] to override whether an account is a returning account.
This could be useful for instance in cases where the user has disconnected the
account out of band.

1. [=Compute the connection status=] of |provider|, |account|, and |globalObject|. If the
result is [=compute the connection status/connected=], set |hasReturningAccount| to
result is [=compute the connection status/connected=], set |isReturningAccount|[|i|] to
true.
1. If |hasReturningAccount| is false, [=reject=] |promise| with a new "{{NetworkError}}"
{{DOMException}}.
1. If |isReturningAccount| does not [=list/contain=] true, [=reject=] |promise| with a new
"{{NetworkError}}" {{DOMException}}.
1. Let |userInfoList| be a new [=list=].
1. For each |account| in |accountsList|:
1. [=list/Append=] an {{IdentityUserInfo}} to |userInfoList| with the following values:
1. Let |notReturningUserInfos| be a new [=list=].
1. For each |i| from 0 to the length of |accountsList| minus 1:
1. Let |account| be |accountsList|[|i|].
1. Let |userInfo| be an {{IdentityUserInfo}} with the following values:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least in the IdentityUserInfo? that way we can expose it to the webpage

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a broader change (adding a webexposed member to the IdentityUserInfo. The goal of this PR is to fix a bug in the existing returned values.


: {{IdentityUserInfo/email}}
:: |account|["{{IdentityProviderAccount/email}}"]
Expand All @@ -1661,6 +1665,9 @@ When invoking the {{IdentityProvider/getUserInfo()}} method given an {{IdentityP
:: |account|["{{IdentityProviderAccount/given_name}}"]
: {{IdentityUserInfo/picture}}
:: |account|["{{IdentityProviderAccount/picture}}"]
1. If |isReturningAccount|[|i|], [=list/append=] |userInfo| to |userInfoList|.
1. Otherwise, [=list/append=] |userInfo| to |notReturningUserInfos|.
1. [=list/Extend=] |userInfo| with |notReturningUserInfos|.
1. [=Resolve=] a new {{Promise}} with |userInfoList|.
</div>

Expand Down
Loading