1
1
/*!
2
- * vue-authenticate v1.3.2
2
+ * vue-authenticate v1.3.3
3
3
* https://github.com/dgrubelic/vue-authenticate
4
4
* Released under the MIT License.
5
5
*/
@@ -39,7 +39,9 @@ function camelCase(name) {
39
39
} ) ;
40
40
}
41
41
42
-
42
+ function isUndefined ( value ) {
43
+ return typeof value === 'undefined'
44
+ }
43
45
44
46
45
47
@@ -492,24 +494,28 @@ var defaultOptions = {
492
494
logoutUrl : null ,
493
495
storageType : 'localStorage' ,
494
496
storageNamespace : 'vue-authenticate' ,
495
- cookieStorage : { } ,
497
+ cookieStorage : {
498
+ domain : window . location . hostname ,
499
+ path : '/' ,
500
+ secure : false
501
+ } ,
496
502
requestDataKey : 'data' ,
497
503
responseDataKey : 'data' ,
498
504
499
505
/**
500
506
* Default request interceptor for Axios library
501
507
* @context {VueAuthenticate}
502
508
*/
503
- bindRequestInterceptor : function ( ) {
504
- var this$1 = this ;
509
+ bindRequestInterceptor : function ( $auth ) {
510
+ var tokenHeader = $auth . options . tokenHeader ;
505
511
506
- this . $http . interceptors . request . use ( function ( config ) {
507
- if ( this$1 . isAuthenticated ( ) ) {
508
- config . headers [ 'Authorization' ] = [
509
- this$1 . options . tokenType , this$1 . getToken ( )
512
+ $auth . $http . interceptors . request . use ( function ( config ) {
513
+ if ( $auth . isAuthenticated ( ) ) {
514
+ config . headers [ tokenHeader ] = [
515
+ $auth . options . tokenType , $auth . getToken ( )
510
516
] . join ( ' ' ) ;
511
517
} else {
512
- delete config . headers [ 'Authorization' ] ;
518
+ delete config . headers [ tokenHeader ] ;
513
519
}
514
520
return config
515
521
} ) ;
@@ -519,11 +525,9 @@ var defaultOptions = {
519
525
* Default response interceptor for Axios library
520
526
* @contect {VueAuthenticate}
521
527
*/
522
- bindResponseInterceptor : function ( ) {
523
- var this$1 = this ;
524
-
525
- this . $http . interceptors . response . use ( function ( response ) {
526
- this$1 . setToken ( response ) ;
528
+ bindResponseInterceptor : function ( $auth ) {
529
+ $auth . $http . interceptors . response . use ( function ( response ) {
530
+ $auth . setToken ( response ) ;
527
531
return response
528
532
} ) ;
529
533
} ,
@@ -533,7 +537,7 @@ var defaultOptions = {
533
537
name : 'facebook' ,
534
538
url : '/auth/facebook' ,
535
539
authorizationEndpoint : 'https://www.facebook.com/v2.5/dialog/oauth' ,
536
- redirectUri : null ,
540
+ redirectUri : window . location . origin + '/' ,
537
541
requiredUrlParams : [ 'display' , 'scope' ] ,
538
542
scope : [ 'email' ] ,
539
543
scopeDelimiter : ',' ,
@@ -546,7 +550,7 @@ var defaultOptions = {
546
550
name : 'google' ,
547
551
url : '/auth/google' ,
548
552
authorizationEndpoint : 'https://accounts.google.com/o/oauth2/auth' ,
549
- redirectUri : null ,
553
+ redirectUri : window . location . origin ,
550
554
requiredUrlParams : [ 'scope' ] ,
551
555
optionalUrlParams : [ 'display' ] ,
552
556
scope : [ 'profile' , 'email' ] ,
@@ -561,7 +565,7 @@ var defaultOptions = {
561
565
name : 'github' ,
562
566
url : '/auth/github' ,
563
567
authorizationEndpoint : 'https://github.com/login/oauth/authorize' ,
564
- redirectUri : null ,
568
+ redirectUri : window . location . origin ,
565
569
optionalUrlParams : [ 'scope' ] ,
566
570
scope : [ 'user:email' ] ,
567
571
scopeDelimiter : ' ' ,
@@ -573,18 +577,19 @@ var defaultOptions = {
573
577
name : 'instagram' ,
574
578
url : '/auth/instagram' ,
575
579
authorizationEndpoint : 'https://api.instagram.com/oauth/authorize' ,
576
- redirectUri : null ,
580
+ redirectUri : window . location . origin ,
577
581
requiredUrlParams : [ 'scope' ] ,
578
582
scope : [ 'basic' ] ,
579
583
scopeDelimiter : '+' ,
580
- oauthType : '2.0'
584
+ oauthType : '2.0' ,
585
+ popupOptions : { width : null , height : null }
581
586
} ,
582
587
583
588
twitter : {
584
589
name : 'twitter' ,
585
590
url : '/auth/twitter' ,
586
591
authorizationEndpoint : 'https://api.twitter.com/oauth/authenticate' ,
587
- redirectUri : null ,
592
+ redirectUri : window . location . origin ,
588
593
oauthType : '1.0' ,
589
594
popupOptions : { width : 495 , height : 645 }
590
595
} ,
@@ -593,7 +598,7 @@ var defaultOptions = {
593
598
name : 'bitbucket' ,
594
599
url : '/auth/bitbucket' ,
595
600
authorizationEndpoint : 'https://bitbucket.org/site/oauth2/authorize' ,
596
- redirectUri : null ,
601
+ redirectUri : window . location . origin + '/' ,
597
602
optionalUrlParams : [ 'scope' ] ,
598
603
scope : [ 'email' ] ,
599
604
scopeDelimiter : ' ' ,
@@ -605,7 +610,7 @@ var defaultOptions = {
605
610
name : 'linkedin' ,
606
611
url : '/auth/linkedin' ,
607
612
authorizationEndpoint : 'https://www.linkedin.com/oauth/v2/authorization' ,
608
- redirectUri : null ,
613
+ redirectUri : window . location . origin ,
609
614
requiredUrlParams : [ 'state' ] ,
610
615
scope : [ 'r_emailaddress' ] ,
611
616
scopeDelimiter : ' ' ,
@@ -618,7 +623,7 @@ var defaultOptions = {
618
623
name : 'live' ,
619
624
url : '/auth/live' ,
620
625
authorizationEndpoint : 'https://login.live.com/oauth20_authorize.srf' ,
621
- redirectUri : null ,
626
+ redirectUri : window . location . origin ,
622
627
requiredUrlParams : [ 'display' , 'scope' ] ,
623
628
scope : [ 'wl.emails' ] ,
624
629
scopeDelimiter : ' ' ,
@@ -631,7 +636,7 @@ var defaultOptions = {
631
636
name : null ,
632
637
url : '/auth/oauth1' ,
633
638
authorizationEndpoint : null ,
634
- redirectUri : null ,
639
+ redirectUri : window . location . origin ,
635
640
oauthType : '1.0' ,
636
641
popupOptions : null
637
642
} ,
@@ -640,7 +645,7 @@ var defaultOptions = {
640
645
name : null ,
641
646
url : '/auth/oauth2' ,
642
647
clientId : null ,
643
- redirectUri : null ,
648
+ redirectUri : window . location . origin ,
644
649
authorizationEndpoint : null ,
645
650
defaultUrlParams : [ 'response_type' , 'client_id' , 'redirect_uri' ] ,
646
651
requiredUrlParams : null ,
@@ -663,9 +668,9 @@ var defaultOptions = {
663
668
664
669
var CookieStorage = function CookieStorage ( defaultOptions ) {
665
670
this . _defaultOptions = objectExtend ( {
666
- domain : null ,
671
+ domain : window . location . hostname ,
667
672
expires : null ,
668
- path : null ,
673
+ path : '/' ,
669
674
secure : false
670
675
} , defaultOptions ) ;
671
676
} ;
@@ -785,7 +790,7 @@ function StorageFactory(options) {
785
790
window . sessionStorage . setItem ( 'testKey' , 'test' ) ;
786
791
window . sessionStorage . removeItem ( 'testKey' ) ;
787
792
return new LocalStorage$2 ( options . storageNamespace )
788
- } catch ( e ) { }
793
+ } catch ( e ) { }
789
794
790
795
case 'cookieStorage' :
791
796
return new CookieStorage ( options . cookieStorage ) ;
@@ -878,7 +883,9 @@ OAuthPopup.prototype._stringifyOptions = function _stringifyOptions () {
878
883
879
884
var options = [ ] ;
880
885
for ( var optionKey in this$1 . popupOptions ) {
881
- options . push ( ( optionKey + "=" + ( this$1 . popupOptions [ optionKey ] ) ) ) ;
886
+ if ( ! isUndefined ( this$1 . popupOptions [ optionKey ] ) ) {
887
+ options . push ( ( optionKey + "=" + ( this$1 . popupOptions [ optionKey ] ) ) ) ;
888
+ }
882
889
}
883
890
return options . join ( ',' )
884
891
} ;
@@ -894,7 +901,7 @@ var defaultProviderConfig = {
894
901
requiredUrlParams : null ,
895
902
defaultUrlParams : null ,
896
903
oauthType : '1.0' ,
897
- popupOptions : { width : null , height : null }
904
+ popupOptions : { }
898
905
} ;
899
906
900
907
var OAuth = function OAuth ( $http , storage , providerConfig , options ) {
@@ -1013,7 +1020,7 @@ var defaultProviderConfig$1 = {
1013
1020
redirectUri : 'redirectUri'
1014
1021
} ,
1015
1022
oauthType : '2.0' ,
1016
- popupOptions : { width : null , height : null }
1023
+ popupOptions : { }
1017
1024
} ;
1018
1025
1019
1026
var OAuth2 = function OAuth2 ( $http , storage , providerConfig , options ) {
@@ -1374,8 +1381,6 @@ VueAuthenticate.prototype.authenticate = function authenticate (provider, userDa
1374
1381
} else {
1375
1382
return reject ( new Error ( 'Authentication failed' ) )
1376
1383
}
1377
- } ) . catch ( function ( ) {
1378
- reject ( new Error ( 'Authentication error occurred' ) ) ;
1379
1384
} )
1380
1385
} )
1381
1386
} ;
0 commit comments