@@ -43,11 +43,11 @@ module.exports = [
4343 controller : 'IndexController' ,
4444 controllerAs : 'COS' ,
4545 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 ( userAndFetchedOrgs ) {
49+ var prevLocation = keypather . get ( userAndGrantedOrgs , 'user. attrs.userOptions.uiState.previousLocation.org' ) ;
50+ var prevInstance = keypather . get ( userAndGrantedOrgs , 'user. attrs.userOptions.uiState.previousLocation.instance' ) ;
5151 if ( prevLocation ) {
5252 if ( prevInstance ) {
5353 $state . go ( 'base.instances.instance' , {
@@ -59,10 +59,14 @@ module.exports = [
5959 userName : prevLocation
6060 } ) ;
6161 }
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+ } ) ;
6266 } else {
6367 $state . go ( 'orgSelect' ) ;
6468 }
65- return user ;
69+ return userAndGrantedOrgs . user ;
6670 } ) ;
6771 }
6872 }
0 commit comments