razzius / weave

Source code for a platform to connect mentors with students
MIT License
7 stars 2 forks source link

Non-auth error clears login tokens #146

Closed razzius closed 4 years ago

razzius commented 4 years ago

Currently:

  async componentDidMount() {
    const { token } = this.state

    if (token !== null && window.location.pathname !== '/verify') {
      try {
        const account = await verifyToken(token)
        this.setState({ account })
      } catch (e) {
        console.error('App componentDidMount: error causing token to clear', e)
        clearToken()
        this.setState({ token: null })
      }
      this.setState({ loading: false })
    }
  }

This means that any error in verifyToken will cause the localstorage to clear. This may be causing logout issues.

razzius commented 4 years ago

Fixed by switching to cookie-based sessions.