mirror of
https://github.com/fergalmoran/roboto-promoto.git
synced 2025-12-22 09:37:37 +00:00
Initial Commit
This commit is contained in:
58
app/scripts/app.js
Normal file
58
app/scripts/app.js
Normal file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
angular.module('robotoApp', [
|
||||
'ngCookies',
|
||||
'ngResource',
|
||||
'ngSanitize',
|
||||
'ngRoute'
|
||||
])
|
||||
.config(function ($routeProvider, $locationProvider, $httpProvider) {
|
||||
$routeProvider
|
||||
.when('/', {
|
||||
templateUrl: 'partials/main',
|
||||
controller: 'MainCtrl'
|
||||
})
|
||||
.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);
|
||||
|
||||
// Intercept 401s and redirect you to login
|
||||
$httpProvider.interceptors.push(['$q', '$location', function($q, $location) {
|
||||
return {
|
||||
'responseError': function(response) {
|
||||
if(response.status === 401) {
|
||||
$location.path('/login');
|
||||
return $q.reject(response);
|
||||
}
|
||||
else {
|
||||
return $q.reject(response);
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
})
|
||||
.run(function ($rootScope, $location, Auth) {
|
||||
|
||||
// Redirect to login if route requires auth and you're not logged in
|
||||
$rootScope.$on('$routeChangeStart', function (event, next) {
|
||||
|
||||
if (next.authenticate && !Auth.isLoggedIn()) {
|
||||
$location.path('/login');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user