Skip to content

Commit

Permalink
feat(aware): add hosted-domain option (Closes #113)
Browse files Browse the repository at this point in the history
  • Loading branch information
satoshun00 authored and addyosmani committed Oct 4, 2015
1 parent d75abd4 commit 9796acb
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
36 changes: 34 additions & 2 deletions google-signin-aware.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
'appPackageName': 'apppackagename',
'clientId': 'clientid',
'cookiePolicy': 'cookiepolicy',
'requestVisibleActions': 'requestvisibleactions'
'requestVisibleActions': 'requestvisibleactions',
'hostedDomain': 'hostedDomain'
};

/**
Expand Down Expand Up @@ -97,6 +98,23 @@
this._requestVisibleActions = val;
},

/**
* oauth2 argument, set by google-signin-aware
*/
_hostedDomain: '',

get hostedDomain() {
return this._hostedDomain;
},

set hostedDomain(val) {
if (this._hostedDomain && val && val != this._hostedDomain) {
throw new Error('hostedDomain cannot change. Values do not match. New: ' + val + ' Old: ' + this._hostedDomain);
}
if (val)
this._hostedDomain = val;
},

/** Is offline access currently enabled in the google-signin-aware element? */
_offline: false,

Expand Down Expand Up @@ -157,7 +175,8 @@
var auth = gapi.auth2.init({
'client_id': this.clientId,
'cookie_policy': this.cookiePolicy,
'scope': this.requestedScopes
'scope': this.requestedScopes,
'hosted_domain': this.hostedDomain
});

auth.currentUser.listen(this.handleUserUpdate.bind(this));
Expand Down Expand Up @@ -513,6 +532,15 @@
observer: '_requestVisibleActionsChanged'
},

/**
* The Google Apps domain to which users must belong to sign in.
* See the relevant [docs](https://developers.google.com/identity/sign-in/web/reference) for more information.
*/
hostedDomain: {
type: String,
observer: '_hostedDomainChanged'
},

/**
* Allows for offline `access_token` retrieval during the signin process.
*/
Expand Down Expand Up @@ -605,6 +633,10 @@
AuthEngine.requestVisibleActions = newVal;
},

_hostedDomainChanged: function(newVal, oldVal) {
AuthEngine.hostedDomain = newVal;
},

_offlineChanged: function(newVal, oldVal) {
AuthEngine.offline = newVal;
},
Expand Down
10 changes: 10 additions & 0 deletions google-signin.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
client-id="{{clientId}}"
cookie-policy="{{cookiePolicy}}"
request-visible-actions="{{requestVisibleActions}}"
hosted-domain="{{hostedDomain}}"
offline="{{offline}}"
scopes="{{scopes}}"
signed-in="{{signedIn}}"
Expand Down Expand Up @@ -329,6 +330,15 @@
value: ''
},

/**
* The Google Apps domain to which users must belong to sign in.
* See the relevant [docs](https://developers.google.com/identity/sign-in/web/reference) for more information.
*/
hostedDomain: {
type: String,
value: ''
},

/**
* Allows for offline `access_token` retrieval during the signin process.
*/
Expand Down

0 comments on commit 9796acb

Please sign in to comment.