Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
87 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,8 @@ handlers: | |
- url: /oauth/.* | ||
script: oauth.py | ||
|
||
- url: /logout/ | ||
script: logout.py | ||
|
||
- url: /.* | ||
script: not_found.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from google.appengine.ext import webapp | ||
from urllib import urlencode | ||
|
||
class BaseHandler(webapp.RequestHandler): | ||
def go_home(self, msg=None): | ||
if msg: | ||
encoded = urlencode({'error_msg': msg}) | ||
self.redirect('/?' + encoded) | ||
else: | ||
self.redirect('/') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from google.appengine.ext import webapp | ||
from google.appengine.ext.webapp.util import run_wsgi_app | ||
from gaesessions import get_current_session | ||
from common import BaseHandler | ||
|
||
import config | ||
import logging | ||
|
||
|
||
class LogoutHandler(BaseHandler): | ||
def get(self): | ||
session = get_current_session() | ||
if session.is_active(): | ||
session.terminate() | ||
self.go_home() | ||
|
||
|
||
application = webapp.WSGIApplication([('/logout/', LogoutHandler)], | ||
debug=True) | ||
|
||
|
||
def main(): | ||
run_wsgi_app(application) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
{% if error_msg %} | ||
<div class="error_msg"> | ||
{{ error_msg }} | ||
</div> | ||
{% endif %} | ||
<h1>You are currently | ||
{% if not has_token %}NOT {% endif %} | ||
logged in{% if scope %} with {{scope}} permission.{%else%}. | ||
{% endif %} | ||
<h2> | ||
<ul> | ||
<li><a href="/oauth/">test oauth</a></li> | ||
<li><a href="/logout/">logout</a></li> | ||
</ul> | ||
</html> |