| Index: appengine/config_service/ui/common/auth-signin.html
|
| diff --git a/appengine/config_service/ui/common/auth-signin.html b/appengine/config_service/ui/common/auth-signin.html
|
| index e41bbad41be9ad632893a618f8b3d4e93293de89..dfc9c32a7d8a13d3683b441ee3ebaecdfe4c9481 100644
|
| --- a/appengine/config_service/ui/common/auth-signin.html
|
| +++ b/appengine/config_service/ui/common/auth-signin.html
|
| @@ -46,6 +46,7 @@
|
|
|
| <google-signin-aware id="aware"
|
| client-id="[[client_id]]"
|
| + initialized="{{initialized}}"
|
| scopes="email"
|
| on-google-signin-aware-success="_onSignin"
|
| on-google-signin-aware-signed-out="_onSignout">
|
| @@ -73,7 +74,7 @@
|
| properties: {
|
| auth_headers: {
|
| type: Object,
|
| - value: () => {},
|
| + value: () => null,
|
| notify: true
|
| },
|
|
|
| @@ -87,6 +88,12 @@
|
| type: String
|
| },
|
|
|
| + initialized: {
|
| + type: Boolean,
|
| + value: false,
|
| + notify: true
|
| + },
|
| +
|
| profile: {
|
| type: Object,
|
| notify: true
|
| @@ -96,6 +103,12 @@
|
| type: Boolean,
|
| value: false,
|
| notify: true
|
| + },
|
| +
|
| + user: {
|
| + type: Object,
|
| + value: () => null,
|
| + notify: true,
|
| }
|
| },
|
|
|
| @@ -111,11 +124,12 @@
|
| // to avoid extraneous errors in the console.
|
| if (!this.signed_in && !this._signingIn){
|
| if (('gapi' in window) && ('auth2' in window.gapi)) {
|
| - var user = gapi.auth2.getAuthInstance().currentUser.get();
|
| - if (user && user.getAuthResponse().access_token) {
|
| + this.set('user', null);
|
| + this.set('user', gapi.auth2.getAuthInstance().currentUser.get());
|
| + if (this.user && this.user.getAuthResponse().access_token) {
|
| // User is already logged in, can use the access_token.
|
| this._onSignin();
|
| - } else {
|
| + } else if (!this.initialized) {
|
| window.setTimeout(this.ready.bind(this), 50);
|
| }
|
| } else {
|
| @@ -127,18 +141,19 @@
|
|
|
| _onSignin: function() {
|
| this._signingIn = true;
|
| - var user = gapi.auth2.getAuthInstance().currentUser.get();
|
| - var profile = { email: user.getBasicProfile().getEmail(),
|
| - imageUrl: user.getBasicProfile().getImageUrl() };
|
| - this.set('profile', {});
|
| + this.set('user', null);
|
| + this.set('user', gapi.auth2.getAuthInstance().currentUser.get());
|
| + var profile = { email: this.user.getBasicProfile().getEmail(),
|
| + imageUrl: this.user.getBasicProfile().getImageUrl() };
|
| + this.set('profile', null);
|
| this.set('profile', profile);
|
| - this.set('auth_response', user.getAuthResponse());
|
| + this.set('auth_response', this.user.getAuthResponse());
|
| this.signed_in = true;
|
| // The credential will expire after a while (usually an hour)
|
| // so we need to reload it.
|
| this.async(function(){
|
| console.log("reloading credentials");
|
| - user.reloadAuthResponse();
|
| + this.user.reloadAuthResponse();
|
| this._onSignin();
|
| }, this.auth_response.expires_in * 1000); // convert seconds to ms
|
| this._signingIn = false;
|
| @@ -151,7 +166,7 @@
|
|
|
| _makeHeader: function() {
|
| if (!this.auth_response) {
|
| - this.set('auth_headers', {});
|
| + this.set('auth_headers', null);
|
| }
|
| this.set('auth_headers',
|
| {
|
|
|