1
1
/*!
2
- * vue-authenticate v1.3.4
2
+ * vue-authenticate v1.3.5-beta.1
3
3
* https://github.com/dgrubelic/vue-authenticate
4
4
* Released under the MIT License.
5
5
*/
@@ -480,6 +480,24 @@ Promise$1._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
480
480
Promise$1 . _unhandledRejectionFn = fn ;
481
481
} ;
482
482
483
+ function getCookieDomainUrl ( ) {
484
+ try {
485
+ return window . location . hostname
486
+ } catch ( e ) { }
487
+
488
+ return '' ;
489
+ }
490
+
491
+ function getRedirectUri ( uri ) {
492
+ try {
493
+ return ( ! isUndefined ( uri ) )
494
+ ? ( "" + ( window . location . origin ) + uri )
495
+ : window . location . origin
496
+ } catch ( e ) { }
497
+
498
+ return uri || null ;
499
+ }
500
+
483
501
/**
484
502
* Default configuration
485
503
*/
@@ -495,7 +513,7 @@ var defaultOptions = {
495
513
storageType : 'localStorage' ,
496
514
storageNamespace : 'vue-authenticate' ,
497
515
cookieStorage : {
498
- domain : window . location . hostname ,
516
+ domain : getCookieDomainUrl ( ) ,
499
517
path : '/' ,
500
518
secure : false
501
519
} ,
@@ -521,23 +539,12 @@ var defaultOptions = {
521
539
} ) ;
522
540
} ,
523
541
524
- /**
525
- * Default response interceptor for Axios library
526
- * @contect {VueAuthenticate}
527
- */
528
- bindResponseInterceptor : function ( $auth ) {
529
- $auth . $http . interceptors . response . use ( function ( response ) {
530
- $auth . setToken ( response ) ;
531
- return response
532
- } ) ;
533
- } ,
534
-
535
542
providers : {
536
543
facebook : {
537
544
name : 'facebook' ,
538
545
url : '/auth/facebook' ,
539
546
authorizationEndpoint : 'https://www.facebook.com/v2.5/dialog/oauth' ,
540
- redirectUri : window . location . origin + '/' ,
547
+ redirectUri : getRedirectUri ( '/' ) ,
541
548
requiredUrlParams : [ 'display' , 'scope' ] ,
542
549
scope : [ 'email' ] ,
543
550
scopeDelimiter : ',' ,
@@ -550,7 +557,7 @@ var defaultOptions = {
550
557
name : 'google' ,
551
558
url : '/auth/google' ,
552
559
authorizationEndpoint : 'https://accounts.google.com/o/oauth2/auth' ,
553
- redirectUri : window . location . origin ,
560
+ redirectUri : getRedirectUri ( ) ,
554
561
requiredUrlParams : [ 'scope' ] ,
555
562
optionalUrlParams : [ 'display' ] ,
556
563
scope : [ 'profile' , 'email' ] ,
@@ -565,7 +572,7 @@ var defaultOptions = {
565
572
name : 'github' ,
566
573
url : '/auth/github' ,
567
574
authorizationEndpoint : 'https://github.com/login/oauth/authorize' ,
568
- redirectUri : window . location . origin ,
575
+ redirectUri : getRedirectUri ( ) ,
569
576
optionalUrlParams : [ 'scope' ] ,
570
577
scope : [ 'user:email' ] ,
571
578
scopeDelimiter : ' ' ,
@@ -577,7 +584,7 @@ var defaultOptions = {
577
584
name : 'instagram' ,
578
585
url : '/auth/instagram' ,
579
586
authorizationEndpoint : 'https://api.instagram.com/oauth/authorize' ,
580
- redirectUri : window . location . origin ,
587
+ redirectUri : getRedirectUri ( ) ,
581
588
requiredUrlParams : [ 'scope' ] ,
582
589
scope : [ 'basic' ] ,
583
590
scopeDelimiter : '+' ,
@@ -589,7 +596,7 @@ var defaultOptions = {
589
596
name : 'twitter' ,
590
597
url : '/auth/twitter' ,
591
598
authorizationEndpoint : 'https://api.twitter.com/oauth/authenticate' ,
592
- redirectUri : window . location . origin ,
599
+ redirectUri : getRedirectUri ( ) ,
593
600
oauthType : '1.0' ,
594
601
popupOptions : { width : 495 , height : 645 }
595
602
} ,
@@ -598,7 +605,7 @@ var defaultOptions = {
598
605
name : 'bitbucket' ,
599
606
url : '/auth/bitbucket' ,
600
607
authorizationEndpoint : 'https://bitbucket.org/site/oauth2/authorize' ,
601
- redirectUri : window . location . origin + '/' ,
608
+ redirectUri : getRedirectUri ( '/' ) ,
602
609
optionalUrlParams : [ 'scope' ] ,
603
610
scope : [ 'email' ] ,
604
611
scopeDelimiter : ' ' ,
@@ -610,7 +617,7 @@ var defaultOptions = {
610
617
name : 'linkedin' ,
611
618
url : '/auth/linkedin' ,
612
619
authorizationEndpoint : 'https://www.linkedin.com/oauth/v2/authorization' ,
613
- redirectUri : window . location . origin ,
620
+ redirectUri : getRedirectUri ( ) ,
614
621
requiredUrlParams : [ 'state' ] ,
615
622
scope : [ 'r_emailaddress' ] ,
616
623
scopeDelimiter : ' ' ,
@@ -623,7 +630,7 @@ var defaultOptions = {
623
630
name : 'live' ,
624
631
url : '/auth/live' ,
625
632
authorizationEndpoint : 'https://login.live.com/oauth20_authorize.srf' ,
626
- redirectUri : window . location . origin ,
633
+ redirectUri : getRedirectUri ( ) ,
627
634
requiredUrlParams : [ 'display' , 'scope' ] ,
628
635
scope : [ 'wl.emails' ] ,
629
636
scopeDelimiter : ' ' ,
@@ -636,7 +643,7 @@ var defaultOptions = {
636
643
name : null ,
637
644
url : '/auth/oauth1' ,
638
645
authorizationEndpoint : null ,
639
- redirectUri : window . location . origin ,
646
+ redirectUri : getRedirectUri ( ) ,
640
647
oauthType : '1.0' ,
641
648
popupOptions : null
642
649
} ,
@@ -645,7 +652,7 @@ var defaultOptions = {
645
652
name : null ,
646
653
url : '/auth/oauth2' ,
647
654
clientId : null ,
648
- redirectUri : window . location . origin ,
655
+ redirectUri : getRedirectUri ( ) ,
649
656
authorizationEndpoint : null ,
650
657
defaultUrlParams : [ 'response_type' , 'client_id' , 'redirect_uri' ] ,
651
658
requiredUrlParams : null ,
@@ -668,7 +675,7 @@ var defaultOptions = {
668
675
669
676
var CookieStorage = function CookieStorage ( defaultOptions ) {
670
677
this . _defaultOptions = objectExtend ( {
671
- domain : window . location . hostname ,
678
+ domain : getCookieDomainUrl ( ) ,
672
679
expires : null ,
673
680
path : '/' ,
674
681
secure : false
@@ -697,13 +704,19 @@ CookieStorage.prototype.removeItem = function removeItem (key) {
697
704
} ;
698
705
699
706
CookieStorage . prototype . _getCookie = function _getCookie ( ) {
700
- return typeof document === 'undefined'
701
- ? '' : typeof document . cookie === 'undefined'
702
- ? '' : document . cookie ;
707
+ try {
708
+ return typeof document === 'undefined'
709
+ ? '' : typeof document . cookie === 'undefined'
710
+ ? '' : document . cookie ;
711
+ } catch ( e ) { }
712
+
713
+ return '' ;
703
714
} ;
704
715
705
716
CookieStorage . prototype . _setCookie = function _setCookie ( cookie ) {
706
- document . cookie = cookie ;
717
+ try {
718
+ document . cookie = cookie ;
719
+ } catch ( e ) { }
707
720
} ;
708
721
709
722
var LocalStorage = function LocalStorage ( namespace ) {
@@ -1189,13 +1202,10 @@ var VueAuthenticate = function VueAuthenticate($http, overrideOptions) {
1189
1202
} ) ;
1190
1203
1191
1204
// Setup request interceptors
1192
- if ( this . options . bindRequestInterceptor && isFunction ( this . options . bindRequestInterceptor ) &&
1193
- this . options . bindResponseInterceptor && isFunction ( this . options . bindResponseInterceptor ) ) {
1194
-
1205
+ if ( this . options . bindRequestInterceptor && isFunction ( this . options . bindRequestInterceptor ) ) {
1195
1206
this . options . bindRequestInterceptor . call ( this , this ) ;
1196
- this . options . bindResponseInterceptor . call ( this , this ) ;
1197
1207
} else {
1198
- throw new Error ( 'Both request and response interceptors must be functions' )
1208
+ throw new Error ( 'Request interceptor must be functions' )
1199
1209
}
1200
1210
} ;
1201
1211
@@ -1328,10 +1338,11 @@ VueAuthenticate.prototype.logout = function logout (requestOptions) {
1328
1338
}
1329
1339
1330
1340
requestOptions = requestOptions || { } ;
1331
- requestOptions . url = requestOptions . logoutUrl || this . options . logoutUrl ;
1332
1341
1333
1342
if ( requestOptions . url ) {
1343
+ requestOptions . url = requestOptions . url ? requestOptions . url : joinUrl ( this . options . baseUrl , this . options . logoutUrl ) ;
1334
1344
requestOptions . method = requestOptions . method || 'POST' ;
1345
+ requestOptions [ this . options . requestDataKey ] = requestOptions [ this . options . requestDataKey ] || undefined ;
1335
1346
requestOptions . withCredentials = requestOptions . withCredentials || this . options . withCredentials ;
1336
1347
1337
1348
return this . $http ( requestOptions ) . then ( function ( response ) {
0 commit comments