gothinkster / react-redux-realworld-example-app

Exemplary real world application built with React + Redux
https://react-redux.realworld.io
MIT License
5.55k stars 2.5k forks source link

Not able to signup and login #139

Closed ankitrhode closed 4 years ago

ankitrhode commented 4 years ago

I am using Django as a backend. React is running on port 3000 and Django on 8000. When I am trying to signup, It's not going to happen. Even though Signup data is reflecting in the Django backend database. "When I click on Sign in/SignUp, It's not redirecting to the next page". Console shows this Uncaught (in promise) TypeError: Cannot read property 'errors' of null at exports.default (auth.js:17) at combination (combineReducers.js:133) at dispatch (createStore.js:178) at redux-logger.js:1 at middleware.js:60 at middleware.js:46 at middleware.js:18 at Object.dispatch (applyMiddleware.js:45) at middleware.js:39

ankitrhode commented 4 years ago

Django backend problem: In apps/authentication/models.py Fix the issue by making the following change:

token = jwt.encode({
        'id': self.pk,
        'exp': datetime.now()+ timedelta(days=60)
    }, settings.SECRET_KEY, algorithm='HS256')

    return token.decode('utf-8')