I’m using Google App Engine (Python), and using OpenID for login. Specifically, I’m playing with the GitHub project from “metachris” here: https://github.com/metachris/appengine-boilerplate
I believe the relevant section of code (App Handler for Login) is here:
class LogIn(webapp.RequestHandler):
def get(self):
user = users.get_current_user()
action = decode(self.request.get('action'))
target_url = decode(self.request.get('continue'))
if action and action == "verify":
f = decode(self.request.get('openid_identifier'))
url = users.create_login_url(target_url, federated_identity=f)
self.redirect(url)
else:
self.response.out.write(template.render(tdir + "login.html", \
{"continue_to": target_url}))
And the login.html code includes:
<!-- Simple OpenID Selector -->
<form action="/login" method="get" id="openid_form">
<input type="hidden" name="action" value="verify" />
{% if continue_to %}<input type="hidden" name="continue" value="{{ continue_to }}" />{% endif %}
<fieldset>
<legend>Sign-in or Create New Account</legend>
<div id="openid_choice">
<p>Please click your account provider:</p>
<div id="openid_btns"></div>
</div>
<div id="openid_input_area">
<input id="openid_identifier" name="openid_identifier" type="text" value="http://" />
<input id="openid_submit" type="submit" value="Sign-In"/>
</div>
</fieldset>
</form>
<!-- /Simple OpenID Selector -->
Right now, after logging in the app takes people back to the root page. I’d like to take them to a new home page for logged in users. I’ve tried varying a bunch of the parameters but I haven’t gotten it to work.
Can anyone point me where I’m going wrong?
You didn’t say, are you setting the ‘continue’ query parameter on your login url? If not, try
/login?continue=/logged-in.First time around
target_urlis being set from the query parameter, it’s then being fed into your form usingcontinue_to. The result of it being in the form is that the query parameter will persist when you submit the form. Next time around, becauseverifyis now set,target_urlwill be fed tocreate_login_url(). Assuming the openid code does the right thing, your openid provider should redirect the user back to/logged-in.