-
Notifications
You must be signed in to change notification settings - Fork 251
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
Don't reference window in default options if it doesn't exist #73
base: master
Are you sure you want to change the base?
Changes from 1 commit
4709e57
77976c8
ba3bf2c
3435bf9
8d398d4
3794148
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import { isUndefined } from './utils.js'; | ||
|
||
|
||
function getCookieDomain() { | ||
return isUndefined(window) ? '' : `${window.location.hostname}`; | ||
} | ||
|
||
function getCookieDomainUrl(path = '') { | ||
return isUndefined(window) ? path : `${window.location.origin}${path}`; | ||
} | ||
/** | ||
* Default configuration | ||
*/ | ||
|
@@ -13,7 +23,7 @@ export default { | |
storageType: 'localStorage', | ||
storageNamespace: 'vue-authenticate', | ||
cookieStorage: { | ||
domain: typeof(window) === 'undefined' ? '' : window.location.hostname, | ||
domain: getCookieDomain(), | ||
path: '/', | ||
secure: false | ||
}, | ||
|
@@ -55,7 +65,7 @@ export default { | |
name: 'facebook', | ||
url: '/auth/facebook', | ||
authorizationEndpoint: 'https://www.facebook.com/v2.5/dialog/oauth', | ||
redirectUri: typeof(window) === 'undefined' ? '/' : window.location.origin + '/', | ||
redirectUri: getCookieDomainUrl('/'), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not good. You are using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ack good point, this time around missed the distinction that we were using hostname in just the first domain, origin in the rest. Fixing. |
||
requiredUrlParams: ['display', 'scope'], | ||
scope: ['email'], | ||
scopeDelimiter: ',', | ||
|
@@ -68,7 +78,7 @@ export default { | |
name: 'google', | ||
url: '/auth/google', | ||
authorizationEndpoint: 'https://accounts.google.com/o/oauth2/auth', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
requiredUrlParams: ['scope'], | ||
optionalUrlParams: ['display'], | ||
scope: ['profile', 'email'], | ||
|
@@ -83,7 +93,7 @@ export default { | |
name: 'github', | ||
url: '/auth/github', | ||
authorizationEndpoint: 'https://github.com/login/oauth/authorize', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
optionalUrlParams: ['scope'], | ||
scope: ['user:email'], | ||
scopeDelimiter: ' ', | ||
|
@@ -95,7 +105,7 @@ export default { | |
name: 'instagram', | ||
url: '/auth/instagram', | ||
authorizationEndpoint: 'https://api.instagram.com/oauth/authorize', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
requiredUrlParams: ['scope'], | ||
scope: ['basic'], | ||
scopeDelimiter: '+', | ||
|
@@ -107,7 +117,7 @@ export default { | |
name: 'twitter', | ||
url: '/auth/twitter', | ||
authorizationEndpoint: 'https://api.twitter.com/oauth/authenticate', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
oauthType: '1.0', | ||
popupOptions: { width: 495, height: 645 } | ||
}, | ||
|
@@ -116,7 +126,7 @@ export default { | |
name: 'bitbucket', | ||
url: '/auth/bitbucket', | ||
authorizationEndpoint: 'https://bitbucket.org/site/oauth2/authorize', | ||
redirectUri: typeof(window) === 'undefined' ? '/' : window.location.origin + '/', | ||
redirectUri: getCookieDomainUrl('/'), | ||
optionalUrlParams: ['scope'], | ||
scope: ['email'], | ||
scopeDelimiter: ' ', | ||
|
@@ -128,7 +138,7 @@ export default { | |
name: 'linkedin', | ||
url: '/auth/linkedin', | ||
authorizationEndpoint: 'https://www.linkedin.com/oauth/v2/authorization', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
requiredUrlParams: ['state'], | ||
scope: ['r_emailaddress'], | ||
scopeDelimiter: ' ', | ||
|
@@ -141,7 +151,7 @@ export default { | |
name: 'live', | ||
url: '/auth/live', | ||
authorizationEndpoint: 'https://login.live.com/oauth20_authorize.srf', | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
requiredUrlParams: ['display', 'scope'], | ||
scope: ['wl.emails'], | ||
scopeDelimiter: ' ', | ||
|
@@ -154,7 +164,7 @@ export default { | |
name: null, | ||
url: '/auth/oauth1', | ||
authorizationEndpoint: null, | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
oauthType: '1.0', | ||
popupOptions: null | ||
}, | ||
|
@@ -163,7 +173,7 @@ export default { | |
name: null, | ||
url: '/auth/oauth2', | ||
clientId: null, | ||
redirectUri: typeof(window) === 'undefined' ? '' : window.location.origin, | ||
redirectUri: getCookieDomainUrl(), | ||
authorizationEndpoint: null, | ||
defaultUrlParams: ['response_type', 'client_id', 'redirect_uri'], | ||
requiredUrlParams: null, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Contextually, you are not returning
CookieDomainUrl
butredirectUri
, sogetRedirectUri
would be a much better name for this function.