forked from angular-ui/AngularJS-StyleGuide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAuthenticated.js
34 lines (31 loc) · 970 Bytes
/
Authenticated.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
/*
Authentication Module
=====================
Most of the actual app is located under here. This abstract module primarily tackles authenticating the user
*/
var module = angular.module('App.Authenticated', ['ui.router'])
module.config(function($stateProvider)
$stateProvider.state('authenticated', {
templateUrl: 'modules/Authenticated/Authenticated.html',
abstract: true,
resolve: {
authenticatedUser: (User, Authentication, $state, $q, $http) => {
return Authentication.checkCredentials().then((response) => {
return new User(response.data);
}, (error) => {
// must return a rejected promise in order to stay in rejected-mode
return $q.reject( $state.go('login') );
});
},
breadcrumbs: () => {
return [];
}
},
onEnter: (user) => {
user.open();
},
onExit: (user) => {
user.close();
}
});
});