Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2745)

Unified Diff: appengine/config_service/ui/common/auth-signin.html

Issue 2980973002: config_service: Fixed multiple ajax requests in the front page while the page determines whether a … (Closed)
Patch Set: Nit: formatting of if statement Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | appengine/config_service/ui/src/config-ui/config-ui.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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',
{
« no previous file with comments | « no previous file | appengine/config_service/ui/src/config-ui/config-ui.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698