finish redux feature parity

This commit is contained in:
41666 2017-12-16 17:39:53 -06:00
parent f5220aa6dc
commit 5510d5a1c4
29 changed files with 220 additions and 100 deletions

View file

@ -14,19 +14,23 @@ export const fetchServers = async dispatch => {
}
export const userInit = async dispatch => {
try {
const rsp = await superagent.get('/api/auth/user')
dispatch({
type: Symbol.for('set user'),
data: rsp.body
})
if (!window.location.pathname.startsWith('/oauth')) {
try {
const rsp = await superagent.get('/api/auth/user')
dispatch(fetchServers)
} catch (e) {
if (!window.location.pathname.startsWith('/oauth')) {
dispatch({
type: Symbol.for('set user'),
data: rsp.body
})
dispatch(fetchServers)
} catch (e) {
window.location.href = '/oauth/flow'
}
} else {
dispatch({
type: Symbol.for('app ready')
})
}
}