1
- export function RoutesRun ( $rootScope , $state , $auth , AclService , $timeout , API ) {
1
+ export function RoutesRun ( $rootScope , $state , $auth , AclService , $timeout , API , ContextService ) {
2
2
'ngInject'
3
3
4
4
AclService . resume ( )
5
5
6
- if ( $auth . isAuthenticated ( ) ) {
7
- let UserData = API . service ( 'me' , API . all ( 'users' ) )
8
- UserData . one ( ) . get ( )
9
- . then ( ( response ) => {
10
- $rootScope . me = API . copy ( response )
11
- } )
12
- }
13
-
14
6
/*eslint-disable */
15
7
let deregisterationCallback = $rootScope . $on ( '$stateChangeStart' , function ( event , toState ) {
16
8
if ( toState . data && toState . data . auth ) {
@@ -23,8 +15,9 @@ export function RoutesRun ($rootScope, $state, $auth, AclService, $timeout, API)
23
15
$rootScope . bodyClass = 'hold-transition login-page'
24
16
} )
25
17
26
- function fixSideBar ( ) {
18
+ function stateChange ( ) {
27
19
$timeout ( function ( ) {
20
+ // fix sidebar
28
21
var neg = $ ( '.main-header' ) . outerHeight ( ) + $ ( '.main-footer' ) . outerHeight ( )
29
22
var window_height = $ ( window ) . height ( )
30
23
var sidebar_height = $ ( '.sidebar' ) . height ( )
@@ -38,10 +31,19 @@ export function RoutesRun ($rootScope, $state, $auth, AclService, $timeout, API)
38
31
$ ( '.content-wrapper, .right-side' ) . css ( 'min-height' , sidebar_height )
39
32
}
40
33
}
34
+
35
+ // get user current context
36
+ if ( $auth . isAuthenticated ( ) && ! $rootScope . me ) {
37
+ ContextService . getContext ( )
38
+ . then ( ( response ) => {
39
+ response = response . plain ( )
40
+ $rootScope . me = response . data
41
+ } )
42
+ }
41
43
} )
42
44
}
43
45
44
46
$rootScope . $on ( '$destroy' , deregisterationCallback )
45
- $rootScope . $on ( '$stateChangeSuccess' , fixSideBar )
47
+ $rootScope . $on ( '$stateChangeSuccess' , stateChange )
46
48
/*eslint-enable */
47
49
}
0 commit comments