Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions client/config/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ module.exports = [
controller: 'IndexController',
controllerAs: 'COS',
resolve: {
user: function ($state, fetchUser, keypather) {
return fetchUser()
.then(function (user) {
var prevLocation = keypather.get(user, 'attrs.userOptions.uiState.previousLocation.org');
var prevInstance = keypather.get(user, 'attrs.userOptions.uiState.previousLocation.instance');
user: function ($q, $state, fetchUser, fetchGrantedGithubOrgs, keypather) {
return $q.all({ user: fetchUser(), grantedOrgs: fetchGrantedGithubOrgs() })
.then(function (userAndGrantedOrgs) {
var prevLocation = keypather.get(userAndGrantedOrgs, 'user.attrs.userOptions.uiState.previousLocation.org');
var prevInstance = keypather.get(userAndGrantedOrgs, 'user.attrs.userOptions.uiState.previousLocation.instance');
if (prevLocation) {
if (prevInstance) {
$state.go('base.instances.instance', {
Expand All @@ -59,10 +59,14 @@ module.exports = [
userName: prevLocation
});
}
} else if (!keypather.get(userAndGrantedOrgs, 'grantedOrgs.models.length')) {
$state.go('base.instances', {
userName: keypather.get(userAndGrantedOrgs, 'user.attrs.accounts.github.username')
});
} else {
$state.go('orgSelect');
}
return user;
return userAndGrantedOrgs.user;
});
}
}
Expand Down