-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
104 lines (99 loc) · 2.85 KB
/
app.js
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var app = angular.module('tmht', ['ui.bootstrap', 'ngRoute', 'ngCookies', 'btford.socket-io', 'ngAutocomplete']);
// Set routes and controllers for each website
app.config(['$routeProvider', function($routeProvider){
$routeProvider.
when('/', {
templateUrl: 'client/views/home.html',
controller: 'loginCtrl',
access: {restricted: false}
}).
when('/signUp', {
templateUrl: 'client/views/signUp.html',
controller: 'signUpCtrl',
access: {restricted: false}
}).
when('/userSettings', {
templateUrl: 'client/views/userSettings.html',
controller: 'userSettingsCtrl',
access: {restricted: true}
}).
when('/landing', {
templateUrl: 'client/views/landing.html',
access: {restricted: true}
}).
when('/rides/ridesOffered', {
templateUrl: 'client/views/rides.html',
controller: 'rides',
access: {restricted: true}
}).
when('/rides/ridesNeeded', {
templateUrl: 'client/views/rides.html',
controller: 'rides',
access: {restricted: true}
}).
when('/rides/requestRide', {
templateUrl: 'client/views/ridesForm.html',
controller: 'rideFormCtrl',
access: {restricted: true}
}).
when('/rides/addRide', {
templateUrl: 'client/views/ridesForm.html',
controller: 'rideFormCtrl',
access: {restricted: true}
}).
when('/rides/ride', {
templateUrl: 'client/views/ridePage.html',
controller: 'ridePage',
access: {restricted: true}
}).
when('/rides/offer', {
templateUrl: 'client/views/ridePage.html',
controller: 'ridePage',
access: {restricted: true}
}).
when('/team', {
templateUrl: 'client/views/team.html',
access: {restricted: false}
}).
when('/publicTransit', {
templateUrl: 'client/views/publicTransit.html',
access: {restricted: true}
}).
when('/taxi', {
templateUrl: 'client/views/taxi.html',
controller: 'taxiCtrl',
access: {restricted: true}
}).
when('/plane', {
templateUrl: 'client/views/plane.html',
controller: 'planeCtrl',
access: {restricted: true}
}).
when('/shuttle', {
templateUrl: 'client/views/shuttle.html',
access: {restricted: true}
}).
when('/buses', {
templateUrl: 'client/views/buses.html',
controller: 'busesCtrl',
access: {restricted: true}
}).
// if other page redirect to other page
otherwise({
redirectTo: '/'
})
}]);
app.run(['$rootScope', '$window', '$route', 'AuthService', function ($rootScope, $window, $route, AuthService) {
$rootScope.$on('$routeChangeStart', function (event, next, current) {
AuthService.checkSessionStatus().then(function(data){
if(data.data == false){
AuthService.removeUser();
}
if (next.$$route != undefined && next.$$route.access != undefined && next.$$route.access.restricted && /*!data.data*/ (AuthService.getUserStatus() == '' || AuthService.getUserStatus() == undefined)) {
AuthService.removeUser();
alert("You are not authorize or not logged in");
$window.location = '/';
}
});
});
}]);