Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
Start of Google-or-OpenID logins.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradfitz committed Mar 14, 2010
1 parent b47c678 commit 06c1c13
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ handlers:
static_dir: static

- url: /s/create
login: required
script: main.py

- url: /s/login
script: main.py

- url: /s/openid
script: consumer.py

- url: /s/login
- url: /s/startopenid
script: consumer.py

- url: /s/finish
Expand Down
2 changes: 1 addition & 1 deletion consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def get(self):
# Map URLs to our RequestHandler subclasses above
_URLS = [
('/s/openid', FrontPage),
('/s/login', LoginHandler),
('/s/startopenid', LoginHandler),
('/s/finish', FinishHandler),
]

Expand Down
30 changes: 30 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<html>
<head>
<title>Log in - Contributing</title>
<link rel='stylesheet' href='/static/style.css' type='text/css' />
</head>
<body>
<h1>Contributing: Log in</h1>

{% if user %}
<p>Hello, <b>{{ user.email }}</b>.</p>
{% else %]
<p>Not logged in.</p>
{% endif %}

<p>Choose your authentication mechanism:<p>

<form method='/s/startopenid' method='POST'>
<div style='margin: 2em 0 2em 0'>
<img src='/static/openid-logo2.png' width='112' height='36' alt='OpenID' align='absmiddle' /><br/>
<input type='text' name='openid_url' id='openid_url' size='40' />
<input type='submit' name='use_openid' value='Log in' />
</nobr></div>
</form>

<div style='margin: 2em 0 2em 0'>
<img src='/static/google-logo.png' width='99' height='36' alt='Google' align='absmiddle' /><br/>
<a href='{{ google_login_url }}'>Log in</a> with your Google Account.
</div>
</body>
</html>
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ def get(self):
self.response.out.write("I'm a site page.")


class LoginHandler(webapp.RequestHandler):

def get(self):
user = users.get_current_user()
google_login_url = users.create_login_url('/')
template_values = {
"user": user,
"google_login_url": google_login_url,
}
self.response.out.write(template.render("login.html", template_values))


class CreateHandler(webapp.RequestHandler):

def get(self):
Expand Down Expand Up @@ -98,6 +110,7 @@ def main():
application = webapp.WSGIApplication([
('/', MainHandler),
('/s/create', CreateHandler),
('/s/login', LoginHandler),
('/s/.*', SiteHandler),
(r'/([a-z][a-z0-9\.\-]*[a-z0-9])/?', ProjectHandler),
],
Expand Down
Binary file added static/google-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added static/openid-logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 06c1c13

Please sign in to comment.