coto / gae-boilerplate

Google App Engine Boilerplate
https://dev-dot-sandengine.appspot.com/
Other
684 stars 188 forks source link

Sessions not correct after clearing users #278

Closed robertdodd closed 10 years ago

robertdodd commented 10 years ago

If you reset the datastore while logged in, the handlers will detect a valid user but if you try access it there will be an error.

Example from the contact page: self.user will be true, but self.user_key fails.

Steps to reproduce:

  1. Start the app from GoogleAppEngineConsole.
  2. Register an account.
  3. Activate the account. (SDK Console -> Datastore Viewer -> Log Email -> First Item -> Find the link in the body property)
  4. You should be logged in.
  5. Stop the app from the GoogleAppEngineConsole.
  6. Double click on the app. Make sure Clear datastore on launch is checked.
  7. Restart the app, and directly navigate to localhost:8080/contact

You will get the following error: AttributeError: 'NoneType' object has no attribute 'name'

Strangely, if you navigate to the home page first and then to the contact page it works fine. I had a bad time though because my home page was throwing the error.

robertdodd commented 10 years ago

I found that using self.current_user instead of self.user works. It returns None like it's supposed to.

Is this the correct usage of self.current_user?

coto commented 10 years ago

Yes, that is correct!!!