Skip to content

Commit 56d12fc

Browse files
committed
fix(client:auth): fix auth 'decorator'
closes #1492
1 parent ecf9014 commit 56d12fc

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Diff for: app/templates/client/components/auth(auth)/router.decorator.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,29 @@ angular.module('<%= scriptAppName %>.auth')
1010
return;
1111
}
1212

13-
let query = typeof next.authenticate === 'string' ? Auth.hasRole : Auth.isLoggedIn;
13+
if(typeof next.authenticate === 'string') {
14+
Auth.hasRole(next.authenticate, _.noop).then(has => {
15+
if(has) {
16+
return;
17+
}
1418

15-
query(1,2).then(good => {
16-
if(!good) {
1719
event.preventDefault();
18-
Auth.isLoggedIn().then(is => {<% if (filters.ngroute) { %>
20+
return Auth.isLoggedIn().then(is => {<% if (filters.ngroute) { %>
1921
$location.path(is ? '/' : '/login');<% } if (filters.uirouter) { %>
2022
$state.go(is ? 'main' : 'login');<% } %>
2123
});
22-
}
23-
});
24+
})
25+
} else {
26+
Auth.isLoggedIn(_.noop).then(is => {
27+
if(is) {
28+
return;
29+
}
30+
31+
event.preventDefault();<% if (filters.ngroute) { %>
32+
$location.path('/');<% } if (filters.uirouter) { %>
33+
$state.go('main');<% } %>
34+
});
35+
}
2436
});
2537
});
2638

0 commit comments

Comments
 (0)