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

feat(aware): add hosted-domain option #113

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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