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

[feature-request] declarative access to currentUser #98

Open
Scarygami opened this issue Jun 8, 2015 · 10 comments
Open

[feature-request] declarative access to currentUser #98

Scarygami opened this issue Jun 8, 2015 · 10 comments

Comments

@Scarygami
Copy link
Contributor

As opposed to waiting for the google-signin-success event or binding to signedIn and observing changes, and then getting the user information as gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile() it would be nice to have this information exposed as currentUser property that could be bound to instead of signedIn.

That would simplify creating a log-in UI that displays name/picture of the logged in user after a successful authentication.
Sample
google-signin-user-sample1
google-signin-user-sample2

Not really essential since it's easy enough to create yourself, but people wouldn't have to know/learn about the gapi.auth2 calls that way.

@atotic
Copy link
Contributor

atotic commented Jun 8, 2015

We had that in original implementation, but decided to take it out. The reasoning was that we were replicating gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().

It might come back in one day, I am counting your vote :)

Note to self, a nice way to do it would be:

basicProfile: {
    computed: 'getBasicProfile(signedIn)'
}

@atotic atotic closed this as completed Jun 8, 2015
@ebidel ebidel reopened this Jun 8, 2015
@ebidel
Copy link
Contributor

ebidel commented Jun 8, 2015

I think we should provide this to uses. We ended up doing the exact same thing for the I/O web app. There's clearly a need for a computed property :)

@Scarygami
Copy link
Contributor Author

As for "replicating": Isn't the main purpose of this element to replicate the behaviour of the gapi.auth2 methods, hiding the complexity of the actual calls? ;)

@ebidel
Copy link
Contributor

ebidel commented Jun 8, 2015

+1. The whole point of these components is to smooth over API complexities.

@atotic atotic self-assigned this Jun 8, 2015
@atotic
Copy link
Contributor

atotic commented Jun 18, 2015

Do we want to expose any additional information, such as getBasicInfo() if available?

@Scarygami
Copy link
Contributor Author

I think just having the user information available (without having to call any extra methods) would be best. The BasicProfile object you get is a bit strange in JS terms, since you have to use get-Methods to get the actual values, a behavior that I would hide for the computed property to allow direct data binding, something like:

_computeUser: function (signedIn) {
  if (!signedIn) { return undefined; }
  var profile = gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile();
  return {
    id: profile.getId(),
    name: profile.getName(),
    email: profile.getEmail(),
    imageUrl: profile.getImageUrl()
  };
}

getBasicProfile() could be undefined depending on the scopes used in which case only the id of the user would be available via gapi.auth2.getAuthInstance().currentUser.get().getId()

One extra thing that might make sense is to expose the AuthResponse object as computed property as well (gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse()) in case people want to use the access_token / id_token directly outside of the JS client library.

@masonlouchart
Copy link
Contributor

Some news about it? The _computeUser method proposed by @Scarygami could be "enough"?

@masonlouchart
Copy link
Contributor

masonlouchart commented May 25, 2016

The feature shown by @ebidel at the Google I/O will be available soon or is still to be implemented ?

@ebidel
Copy link
Contributor

ebidel commented May 26, 2016

Which feature? We didn't use anything new for sign in this year.

On Wed, May 25, 2016, 11:58 AM Mason Louchart notifications@github.com
wrote:

The feature shown at the Google I/O
https://www.youtube.com/watch?v=__KvYxcIIm8&feature=youtu.be&t=22m52s
will be available soon or is still to be implemented ?


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#98 (comment)

@atotic
Copy link
Contributor

atotic commented May 26, 2016

The <google-signin> in the video has a user property. That's what this feature request is all about.

@atotic atotic removed their assignment Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants