({ commit, dispatch })
| 16 | |
| 17 | export default { |
| 18 | async doInit({ commit, dispatch }) { |
| 19 | try { |
| 20 | const token = AuthToken.get(); |
| 21 | if (token) { |
| 22 | const currentUser = await AuthService.fetchMe(); |
| 23 | connectSocket(token); |
| 24 | commit('AUTH_INIT_SUCCESS', { currentUser }); |
| 25 | return currentUser; |
| 26 | } |
| 27 | |
| 28 | disconnectSocket(); |
| 29 | commit('AUTH_INIT_ERROR'); |
| 30 | return null; |
| 31 | } catch (error) { |
| 32 | console.error(error); |
| 33 | disconnectSocket(); |
| 34 | commit('AUTH_INIT_ERROR'); |
| 35 | dispatch('doSignout'); |
| 36 | return null; |
| 37 | } finally { |
| 38 | ProgressBar.done(); |
| 39 | } |
| 40 | }, |
| 41 | |
| 42 | doWaitUntilInit({ getters }) { |
| 43 | if (!getters.loadingInit) { |
nothing calls this directly
no test coverage detected