-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathapp.coffee
37 lines (33 loc) · 1.29 KB
/
app.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict'
angular.module('<%= scriptAppName %>', [<%= angularModules %>])<% if (ngRoute) { %>
.config ($routeProvider, $locationProvider<% if (mongoPassportUser) { %>, $httpProvider<% } %>) ->
$routeProvider
.when '/',
templateUrl: 'partials/main'
controller: 'MainCtrl'
<% if(mongoPassportUser) {%>
.when '/login',
templateUrl: 'partials/login'
controller: 'LoginCtrl'
.when '/signup',
templateUrl: 'partials/signup'
controller: 'SignupCtrl'
.when '/settings',
templateUrl: 'partials/settings'
controller: 'SettingsCtrl'
authenticate: true<% } %>
.otherwise
redirectTo: '/'
$locationProvider.html5Mode true<% if (mongoPassportUser) { %>
$httpProvider.interceptors.push ['$q', '$location', ($q, $location) ->
responseError: (response) ->
if response.status is 401 or response.status is 403
$location.path '/login'
$q.reject response
else
$q.reject response
]
.run ($rootScope, $location, Auth) ->
# Redirect to login if route requires auth and you're not logged in
$rootScope.$on '$routeChangeStart', (event, next) ->
$location.path '/login' if next.authenticate and not Auth.isLoggedIn()<% } %><% } %>