Skip to content

Commit 5a3fc7d

Browse files
committed
listen for $stateChangeStart with ui-router
fixes #292
1 parent 93b0298 commit 5a3fc7d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Diff for: app/templates/client/app/app(coffee).coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
3434
)
3535
.run (($rootScope, $location, Auth) ->
3636
# Redirect to login if route requires auth and you're not logged in
37-
$rootScope.$on '$routeChangeStart', (event, next) ->
37+
$rootScope.$on <% if(filters.ngroute) { %>'$routeChangeStart'<% } %><% if(filters.uirouter) { %>'$stateChangeStart'<% } %>, (event, next) ->
3838
$location.path '/login' if next.authenticate and not Auth.isLoggedIn()
3939
)<% } %>

Diff for: app/templates/client/app/app(js).js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ angular.module('<%= scriptAppName %>', [<%= angularModules %>])
4545

4646
.run(function ($rootScope, $location, Auth) {
4747
// Redirect to login if route requires auth and you're not logged in
48-
$rootScope.$on('$routeChangeStart', function (event, next) {
48+
$rootScope.$on(<% if(filters.ngroute) { %>'$routeChangeStart'<% } %><% if(filters.uirouter) { %>'$stateChangeStart'<% } %>, function (event, next) {
4949
if (next.authenticate && !Auth.isLoggedIn()) {
5050
$location.path('/login');
5151
}

0 commit comments

Comments
 (0)