Detecting first time login of user into application (Google Appengine)

Posted by Jake on Stack Overflow See other posts from Stack Overflow or by Jake
Published on 2009-06-23T10:40:42Z Indexed on 2010/04/18 6:43 UTC
Read the original article Hit count: 379

My app requires users to login using their google account.

I have this set in my App.yamp file:

  • url: /user/.*
    script: user.py
    login: required

Now when any user tries to access files under /user/secret.py he will need to authenticate via google, which will redirect the user back to /user/secret.py after successful authentication. Now the problem I am facing is when the user is redirected back to the app, I cannot be sure if this is the first time the user has logged in or is it a regular user to my site who has come back again from just the user object which google passes using users.get_current_user() .

I thus need to maintain state in the datastore to check if the user already exists or not everytime. If he does not exist i need to create a new entry with other application specific settings.

My question is: Is there some easier way to handle this? without having to query the datastore to figure if this is a first time user or a regular one?

© Stack Overflow or respective owner

Related posts about google-app-engine

Related posts about google-datastore