@@ -820,7 +820,7 @@ var userappModule = angular.module('UserApp', []);
820
820
} ) ;
821
821
822
822
// OAuth URL directive
823
- userappModule . directive ( 'uaOauthLink' , function ( $timeout , UserApp ) {
823
+ userappModule . directive ( 'uaOauthLink' , function ( $timeout , $location , UserApp ) {
824
824
return {
825
825
restrict : 'A' ,
826
826
link : function ( scope , element , attrs ) {
@@ -836,19 +836,24 @@ var userappModule = angular.module('UserApp', []);
836
836
scope . loading = true ;
837
837
} ) ;
838
838
839
+ function getHashMode ( ) {
840
+ var hash = $location . absUrl ( ) . replace ( window . location . protocol + '//' + window . location . host + window . location . pathname , '' ) ;
841
+ return hash . replace ( $location . path ( ) , '' ) ;
842
+ } ;
843
+
839
844
var providerId = attrs . uaOauthLink ;
840
845
var scopes = 'uaOauthScopes' in attrs ? ( attrs . uaOauthScopes || '' ) . split ( ',' ) : null ;
841
- var defaultRedirectUrl = window . location . protocol + '//' + window . location . host + window . location . pathname + '# /oauth/callback/';
846
+ var defaultRedirectUrl = window . location . protocol + '//' + window . location . host + window . location . pathname + getHashMode ( ) + ' /oauth/callback/';
842
847
var redirectUri = 'uaOauthRedirectUri' in attrs ? attrs . uaOauthRedirectUri : defaultRedirectUrl ;
843
848
844
- UserApp . OAuth . getAuthorizationUrl ( { provider_id : providerId , redirect_uri : redirectUri , scopes : scopes } , function ( error , result ) {
849
+ UserApp . OAuth . getAuthorizationUrl ( { provider_id : providerId , redirect_uri : redirectUri , scopes : scopes } , function ( error , result ) {
845
850
if ( error ) {
846
851
$timeout ( function ( ) {
847
852
scope . error = error ;
848
853
scope . loading = false ;
849
854
} ) ;
850
855
return handleError ( scope , error , attrs . uaError ) ;
851
- } else {
856
+ } else {
852
857
window . location . href = result . authorization_url ;
853
858
}
854
859
} ) ;
0 commit comments