zerowords
zerowords

Reputation: 3113

What if some users do not need to be users?

At this GAE docs page regarding users services I find this statement:

If your app uses OpenID and the user must sign in, your app will be redirected to the URL /_ah/login_required. You must create a page that lets the user sign in using an OpenID identifier. To specify this page, add an entry to your app.yaml file of the following form:

Some of my users do not need to be users, but are sort of guests who provide input that is stored in the datastore. I don't understand whether the docs mean that in my situation open_id cannot be used, or if it must be used another way. I hope my app can use open_id with the app.yaml done as above but just not asking "guests" to authenticate. Is that right?

My question here has to do with another of my questions which is unanswered and I am trying to develop a demo which will answer that question.

Upvotes: 0

Views: 58

Answers (1)

Dan Holevoet
Dan Holevoet

Reputation: 9183

The section you quoted states that it applies when "the user must sign in". You do not have to force all users to sign in. The docs demonstrate how to configure app.yaml to require sign-in on certain pages. However, they also state:

If an application needs different behavior, the application can implement the user handling itself. See the Users API for more information.

You're in this camp. You can use the Users API to implement the sign-in logic yourself. Here's the simplest example:

from google.appengine.api import users

user = users.get_current_user()
if not user:
  # Handle guest users here or redirect them to sign-in if required.
else:
  # This user is signed in.

Upvotes: 1

Related Questions