cmosguy / react-redux-auth0

Using kriasoft/react-starter-kit/tree/feature/redux/ with Auth0 example
MIT License
2 stars 3 forks source link

Error loading Me component #6

Open cmosguy opened 8 years ago

cmosguy commented 8 years ago

@langpavel I am having an issue resolving my me component. I made some updates to the code, so here is what you need to know:

  1. I added the "extend" npm package, so that I can merge the config.server.js and config.client.js files so that I can have my API keys not chekced into the config files. I will send you these files in a separate email.
  2. In the server.js I am validating the token, if it is expired then it will not load the /api/me endpoint to my API server.
  3. If there is a valid token, then I have setup the disptach('setMe') https://github.com/cmosguy/react-redux-auth0/blob/trying-auth0/src/server.js#L156

I used the setIntl to help me figure out how to architect and setup the me objects. But I am stuck on getting an error if you look in the browser that me is null. I don't understand how to organize and setup me if there is not initial valid token. How do I go about doing this correctly?

I also uncommented the <Me> component from navigation.js but I still have not figured out how to resolve the me.js action to work properly in the initial state situation.

Thanks!

langpavel commented 8 years ago

Hi. I will prepare PR for you with fixes. You probably go in right direction so this should not be hard :-) I think I can find some time in next 24 hours

langpavel commented 8 years ago

Hi, sorry for delay.

  1. At first: For sensitive or/and deploy specific data there is great dotenv module.
  2. credentialsRequired: false doesn't look as best validation method, this way you can only say that token not expired...
  3. sorry, where is the if? :-) You dispatching setMe for every decoded token. This looks good fine if you verify token on your backend..

Please, look at #7 and respect rules in .editorconfig and in package.json for eslint, run npm run lint before you commit, it is really useful for cooperation.. :-)

cmosguy commented 8 years ago

@langpavel ok so I went in and edited all the .editorconfig files you requested. I also have added the .git/hooks/pre-commit hook to run the npm run eslint before all commits.

The problem I had so far was that I:

  1. I could not require('dotenv') within the config.js file. dotenv package will only work on the server so I do not think I am doing this correctly.
  2. I really need help figuring out how to dispatch(setMe) properly. If the token has expire (like you mentioned) or is not valid, I do not want to fetch any data. I think I need to do a session because I really do not understand how to realize this. If you can edit code it would be awesome, but I am really stuck here.

I do not understand what I need to do in order to facilitate the error: TypeError: Cannot read property 'me' of null

Can we please work through the code together? or do you have ideas here what I am doing incorrectly?

Thanks Pavel! Adam