@@ -43,11 +43,11 @@ module.exports = [
43
43
controller : 'IndexController' ,
44
44
controllerAs : 'COS' ,
45
45
resolve : {
46
- user : function ( $state , fetchUser , keypather ) {
47
- return fetchUser ( )
48
- . then ( function ( user ) {
49
- var prevLocation = keypather . get ( user , 'attrs.userOptions.uiState.previousLocation.org' ) ;
50
- var prevInstance = keypather . get ( user , 'attrs.userOptions.uiState.previousLocation.instance' ) ;
46
+ user : function ( $q , $ state, fetchUser , fetchGrantedGithubOrgs , keypather ) {
47
+ return $q . all ( { user : fetchUser ( ) , grantedOrgs : fetchGrantedGithubOrgs ( ) } )
48
+ . then ( function ( userAndGrantedOrgs ) {
49
+ var prevLocation = keypather . get ( userAndGrantedOrgs , 'user. attrs.userOptions.uiState.previousLocation.org' ) ;
50
+ var prevInstance = keypather . get ( userAndGrantedOrgs , 'user. attrs.userOptions.uiState.previousLocation.instance' ) ;
51
51
if ( prevLocation ) {
52
52
if ( prevInstance ) {
53
53
$state . go ( 'base.instances.instance' , {
@@ -59,10 +59,14 @@ module.exports = [
59
59
userName : prevLocation
60
60
} ) ;
61
61
}
62
+ } else if ( ! keypather . get ( userAndGrantedOrgs , 'grantedOrgs.models.length' ) ) {
63
+ $state . go ( 'base.instances' , {
64
+ userName : keypather . get ( userAndGrantedOrgs , 'user.attrs.accounts.github.username' )
65
+ } ) ;
62
66
} else {
63
67
$state . go ( 'orgSelect' ) ;
64
68
}
65
- return user ;
69
+ return userAndGrantedOrgs . user ;
66
70
} ) ;
67
71
}
68
72
}
0 commit comments