Skip to content

Commit

Permalink
Merge pull request #223 from uc-cdis/fix/empty-commons
Browse files Browse the repository at this point in the history
fix(login): better handle new empty commons
  • Loading branch information
frickjack authored Feb 8, 2018
2 parents 0266f4c + 623696f commit ca9a99e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/DataModelGraph/ReduxDataModelGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export const getCounts = (typeList, project, dictionary) => {
};
}
},
err => ({ type: 'FETCH_ERROR', error: err }),
)
.then((msg) => { dispatch(msg); });
};
Expand Down
10 changes: 9 additions & 1 deletion src/Login/ProtectedContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class ProtectedContent extends React.Component {
return Promise.resolve(newState);
}
return store.dispatch(fetchProjects())
.then(() => {
.then((info) => {
//
// The assumption here is that fetchProjects either succeeds or fails.
// If it fails (we won't have any project data), then we need to refresh our api token ...
Expand All @@ -182,8 +182,16 @@ class ProtectedContent extends React.Component {
if (projects) {
// user already has a valid token
return Promise.resolve(newState);
} else if (info.status !== 403) {
// do not authenticate unless we have a 403
// there may be no projects at startup time,
// or some other weirdness ...
// The oauth dance below is only relevent for legacy commons - pre jwt
return Promise.resolve(newState);
}
// else do the oauth dance
// NOTE: this is DEPRECATED now - jwt access token
// works across all services
return store.dispatch(fetchOAuthURL(submissionApiOauthPath))
.then(
oauthUrl => fetchJsonOrText({ path: oauthUrl, dispatch: store.dispatch.bind(store) }))
Expand Down
2 changes: 1 addition & 1 deletion src/Submission/ProjectSubmission.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ProjectSubmission = (props) => {
<MySubmitForm />
<MySubmitTSV project={props.project} />
{ !props.dataIsReady
? <Spinner /> :
? ((props.project !== '_root') ? <Spinner /> : null) :
<MyDataModelGraph project={props.project} /> }
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,13 @@ export const fetchProjects = () => dispatch =>
return {
type: 'RECEIVE_PROJECTS',
data: data.data.project,
status,
};
default:
return {
type: 'FETCH_ERROR',
error: data,
status,
};
}
})
Expand Down

0 comments on commit ca9a99e

Please sign in to comment.