Skip to content

Commit

Permalink
fix(app-info): wait for fetch app info until checking user login
Browse files Browse the repository at this point in the history
fix #475
  • Loading branch information
landonreed committed Sep 5, 2019
1 parent 20e411c commit 8407ed7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/common/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@ function wrapComponentInAuthStrategy (
componentWillMount () {
const {checkLogin, fetchAppInfo, user} = this.props
const userIsLoggedIn: boolean = !!user.token
// Fetch app info before component mounts in order to ensure that checks
// for enabled modules result use the correct config data.
fetchAppInfo()
checkLogin(userIsLoggedIn)
if (userIsLoggedIn) {
this._checkIfAdmin()
}
.then(() => {
checkLogin(userIsLoggedIn)
if (userIsLoggedIn) {
this._checkIfAdmin()
}
})
}

componentWillReceiveProps (nextProps) {
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/actions/status.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function checkJobStatus () {
* commits, the repo URL, and the specific configuration used by the backend
* server.
*/
export function fetchAppInfo () {
export async function fetchAppInfo () {
return async function (dispatch: dispatchFn, getState: getStateFn) {
// fetch info. If an error occurs or response json doesn't match, set
// server info to value indicating an unknown commit and repoUrl
Expand Down

0 comments on commit 8407ed7

Please sign in to comment.