Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(543)

Side by Side Diff: appengine/findit/common/base_handler.py

Issue 2506893003: [Findit] After login, redirect to the targeted page for GETs, but original page for others like POS… (Closed)
Patch Set: Fix nits. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | appengine/findit/common/test/base_handler_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import json 6 import json
7 import logging 7 import logging
8 8
9 from google.appengine.api import users 9 from google.appengine.api import users
10 import jinja2 10 import jinja2
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 content_type = 'text/html' 145 content_type = 'text/html'
146 146
147 if cache_expiry is not None: 147 if cache_expiry is not None:
148 self.response.headers['cache-control'] = ( 148 self.response.headers['cache-control'] = (
149 'max-age=%s, public' % cache_expiry) 149 'max-age=%s, public' % cache_expiry)
150 self.response.headers['Content-Type'] = content_type 150 self.response.headers['Content-Type'] = content_type
151 self.response.write(data) 151 self.response.write(data)
152 152
153 def GetLoginUrl(self): 153 def GetLoginUrl(self):
154 """Returns the login url.""" 154 """Returns the login url."""
155 return users.create_login_url(self.request.referer or self.request.uri) 155 if self.request.method == 'GET':
156 # For GET, all parameters are included in the URL.
157 return users.create_login_url(self.request.url)
158 else:
159 # For others like POST, the parameters could be in the body and include
160 # file, etc. Thus return to the original page if available.
161 return users.create_login_url(self.request.referrer)
156 162
157 def _Handle(self, handler_func): 163 def _Handle(self, handler_func):
158 try: 164 try:
159 if not self._HasPermission(): 165 if not self._HasPermission():
160 template = 'error.html' 166 template = 'error.html'
161 data = { 167 data = {
162 'error_message': 168 'error_message':
163 ('Either not login or no permission. ' 169 ('Either not login or no permission. '
164 'Please login with your google.com account.'), 170 'Please login with your google.com account.'),
165 'login_url': self.GetLoginUrl(), 171 'login_url': self.GetLoginUrl(),
(...skipping 19 matching lines...) Expand all
185 return_code = 500 191 return_code = 500
186 cache_expiry = None 192 cache_expiry = None
187 193
188 self._SendResponse(template, data, return_code, cache_expiry) 194 self._SendResponse(template, data, return_code, cache_expiry)
189 195
190 def get(self): 196 def get(self):
191 self._Handle(self.HandleGet) 197 self._Handle(self.HandleGet)
192 198
193 def post(self): 199 def post(self):
194 self._Handle(self.HandlePost) 200 self._Handle(self.HandlePost)
OLDNEW
« no previous file with comments | « no previous file | appengine/findit/common/test/base_handler_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698