From 0d8de02cdee7f92120a27030f0c3295c417a2175 Mon Sep 17 00:00:00 2001 From: satoshun00 Date: Sun, 4 Oct 2015 07:41:08 +0900 Subject: [PATCH] feat(aware): add hosted-domain option --- google-signin-aware.html | 36 ++++++++++++++++++++++++++++++++++-- google-signin.html | 10 ++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/google-signin-aware.html b/google-signin-aware.html index 27ed780..98ecc2c 100644 --- a/google-signin-aware.html +++ b/google-signin-aware.html @@ -13,7 +13,8 @@ 'appPackageName': 'apppackagename', 'clientId': 'clientid', 'cookiePolicy': 'cookiepolicy', - 'requestVisibleActions': 'requestvisibleactions' + 'requestVisibleActions': 'requestvisibleactions', + 'hostedDomain': 'hostedDomain' }; /** @@ -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, @@ -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)); @@ -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. */ @@ -605,6 +633,10 @@ AuthEngine.requestVisibleActions = newVal; }, + _hostedDomainChanged: function(newVal, oldVal) { + AuthEngine.hostedDomain = newVal; + }, + _offlineChanged: function(newVal, oldVal) { AuthEngine.offline = newVal; }, diff --git a/google-signin.html b/google-signin.html index 18a2340..41d7ce1 100644 --- a/google-signin.html +++ b/google-signin.html @@ -17,6 +17,7 @@ client-id="{{clientId}}" cookie-policy="{{cookiePolicy}}" request-visible-actions="{{requestVisibleActions}}" + hosted-domain="{{hostedDomain}}" offline="{{offline}}" scopes="{{scopes}}" signed-in="{{signedIn}}" @@ -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. */