Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
Merge pull request #843 from Gym/bug-previous-state
Browse files Browse the repository at this point in the history
[Bug] Previous State (History)
  • Loading branch information
lirantal committed Aug 23, 2015
2 parents 51196c5 + c6d2683 commit cfe71bb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
12 changes: 7 additions & 5 deletions modules/core/client/app/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ angular.module(ApplicationConfiguration.applicationModuleName).run(function ($ro

// Record previous state
$rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
$state.previous = {
state: fromState,
params: fromParams,
href: $state.href(fromState, fromParams)
};
if (!fromState.data || !fromState.data.ignoreState) {
$state.previous = {
state: fromState,
params: fromParams,
href: $state.href(fromState, fromParams)
};
}
});
});

Expand Down
5 changes: 4 additions & 1 deletion modules/core/client/config/core.client.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider',
})
.state('not-found', {
url: '/not-found',
templateUrl: 'modules/core/client/views/404.client.view.html'
templateUrl: 'modules/core/client/views/404.client.view.html',
data: {
ignoreState: true
}
});
}
]);
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ angular.module('users').controller('AuthenticationController', ['$scope', '$stat

// OAuth provider request
$scope.callOauthProvider = function (url) {
var redirect_to;

if ($state.previous) {
redirect_to = $state.previous.href;
if ($state.previous && $state.previous.href) {
url += '?redirect_to=' + encodeURIComponent($state.previous.href);
}

// Effectively call OAuth authentication route:
$window.location.href = url + (redirect_to ? '?redirect_to=' + encodeURIComponent(redirect_to) : '');
$window.location.href = url;
};
}
]);

0 comments on commit cfe71bb

Please sign in to comment.