Skip to content

Commit 1ec1b6e

Browse files
author
Timothy E. Johansson
committed
Fixed bug with oauth redirect with html5Mode on or special hashbangs.
1 parent 684462d commit 1ec1b6e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

angularjs.userapp.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ var userappModule = angular.module('UserApp', []);
820820
});
821821

822822
// OAuth URL directive
823-
userappModule.directive('uaOauthLink', function($timeout, UserApp) {
823+
userappModule.directive('uaOauthLink', function($timeout, $location, UserApp) {
824824
return {
825825
restrict: 'A',
826826
link: function(scope, element, attrs) {
@@ -836,19 +836,24 @@ var userappModule = angular.module('UserApp', []);
836836
scope.loading = true;
837837
});
838838

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+
839844
var providerId = attrs.uaOauthLink;
840845
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/';
842847
var redirectUri = 'uaOauthRedirectUri' in attrs ? attrs.uaOauthRedirectUri : defaultRedirectUrl;
843848

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) {
845850
if (error) {
846851
$timeout(function() {
847852
scope.error = error;
848853
scope.loading = false;
849854
});
850855
return handleError(scope, error, attrs.uaError);
851-
}else{
856+
} else {
852857
window.location.href = result.authorization_url;
853858
}
854859
});

0 commit comments

Comments
 (0)