Skip to content

Commit aa8802c

Browse files
author
Henry Mollman
committed
When the user first hits the index page, redirect them to the instances page if they have no granted orgs (i.e. a personal account)
1 parent 6a200b6 commit aa8802c

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

client/config/routes.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)