1
+ import { isUndefined } from './utils.js' ;
2
+
3
+ function getCookieDomainUrl ( path = '' ) {
4
+ return isUndefined ( window ) ? path : `${ window . location . hostname } ${ path } ` ;
5
+ }
1
6
/**
2
7
* Default configuration
3
8
*/
@@ -13,7 +18,7 @@ export default {
13
18
storageType : 'localStorage' ,
14
19
storageNamespace : 'vue-authenticate' ,
15
20
cookieStorage : {
16
- domain : typeof ( window ) === 'undefined' ? '' : window . location . hostname ,
21
+ domain : getCookieDomainUrl ( ) ,
17
22
path : '/' ,
18
23
secure : false
19
24
} ,
@@ -55,7 +60,7 @@ export default {
55
60
name : 'facebook' ,
56
61
url : '/auth/facebook' ,
57
62
authorizationEndpoint : 'https://www.facebook.com/v2.5/dialog/oauth' ,
58
- redirectUri : typeof ( window ) === 'undefined' ? '/' : window . location . origin + '/' ,
63
+ redirectUri : getCookieDomainUrl ( '/' ) ,
59
64
requiredUrlParams : [ 'display' , 'scope' ] ,
60
65
scope : [ 'email' ] ,
61
66
scopeDelimiter : ',' ,
@@ -68,7 +73,7 @@ export default {
68
73
name : 'google' ,
69
74
url : '/auth/google' ,
70
75
authorizationEndpoint : 'https://accounts.google.com/o/oauth2/auth' ,
71
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
76
+ redirectUri : getCookieDomainUrl ( ) ,
72
77
requiredUrlParams : [ 'scope' ] ,
73
78
optionalUrlParams : [ 'display' ] ,
74
79
scope : [ 'profile' , 'email' ] ,
@@ -83,7 +88,7 @@ export default {
83
88
name : 'github' ,
84
89
url : '/auth/github' ,
85
90
authorizationEndpoint : 'https://github.com/login/oauth/authorize' ,
86
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
91
+ redirectUri : getCookieDomainUrl ( ) ,
87
92
optionalUrlParams : [ 'scope' ] ,
88
93
scope : [ 'user:email' ] ,
89
94
scopeDelimiter : ' ' ,
@@ -95,7 +100,7 @@ export default {
95
100
name : 'instagram' ,
96
101
url : '/auth/instagram' ,
97
102
authorizationEndpoint : 'https://api.instagram.com/oauth/authorize' ,
98
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
103
+ redirectUri : getCookieDomainUrl ( ) ,
99
104
requiredUrlParams : [ 'scope' ] ,
100
105
scope : [ 'basic' ] ,
101
106
scopeDelimiter : '+' ,
@@ -107,7 +112,7 @@ export default {
107
112
name : 'twitter' ,
108
113
url : '/auth/twitter' ,
109
114
authorizationEndpoint : 'https://api.twitter.com/oauth/authenticate' ,
110
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
115
+ redirectUri : getCookieDomainUrl ( ) ,
111
116
oauthType : '1.0' ,
112
117
popupOptions : { width : 495 , height : 645 }
113
118
} ,
@@ -116,7 +121,7 @@ export default {
116
121
name : 'bitbucket' ,
117
122
url : '/auth/bitbucket' ,
118
123
authorizationEndpoint : 'https://bitbucket.org/site/oauth2/authorize' ,
119
- redirectUri : typeof ( window ) === 'undefined' ? '/' : window . location . origin + '/' ,
124
+ redirectUri : getCookieDomainUrl ( '/' ) ,
120
125
optionalUrlParams : [ 'scope' ] ,
121
126
scope : [ 'email' ] ,
122
127
scopeDelimiter : ' ' ,
@@ -128,7 +133,7 @@ export default {
128
133
name : 'linkedin' ,
129
134
url : '/auth/linkedin' ,
130
135
authorizationEndpoint : 'https://www.linkedin.com/oauth/v2/authorization' ,
131
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
136
+ redirectUri : getCookieDomainUrl ( ) ,
132
137
requiredUrlParams : [ 'state' ] ,
133
138
scope : [ 'r_emailaddress' ] ,
134
139
scopeDelimiter : ' ' ,
@@ -141,7 +146,7 @@ export default {
141
146
name : 'live' ,
142
147
url : '/auth/live' ,
143
148
authorizationEndpoint : 'https://login.live.com/oauth20_authorize.srf' ,
144
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
149
+ redirectUri : getCookieDomainUrl ( ) ,
145
150
requiredUrlParams : [ 'display' , 'scope' ] ,
146
151
scope : [ 'wl.emails' ] ,
147
152
scopeDelimiter : ' ' ,
@@ -154,7 +159,7 @@ export default {
154
159
name : null ,
155
160
url : '/auth/oauth1' ,
156
161
authorizationEndpoint : null ,
157
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
162
+ redirectUri : getCookieDomainUrl ( ) ,
158
163
oauthType : '1.0' ,
159
164
popupOptions : null
160
165
} ,
@@ -163,7 +168,7 @@ export default {
163
168
name : null ,
164
169
url : '/auth/oauth2' ,
165
170
clientId : null ,
166
- redirectUri : typeof ( window ) === 'undefined' ? '' : window . location . origin ,
171
+ redirectUri : getCookieDomainUrl ( ) ,
167
172
authorizationEndpoint : null ,
168
173
defaultUrlParams : [ 'response_type' , 'client_id' , 'redirect_uri' ] ,
169
174
requiredUrlParams : null ,
0 commit comments