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

Side by Side Diff: appengine/monorail/framework/servlet.py

Issue 1954193002: [Monorail] Implement "Switch accounts" via google.com/a/SelectSession. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebased Created 4 years, 7 months 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style 2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at 3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd 4 # https://developers.google.com/open-source/licenses/bsd
5 5
6 """Base classes for Monorail servlets. 6 """Base classes for Monorail servlets.
7 7
8 This base class provides HTTP get() and post() methods that 8 This base class provides HTTP get() and post() methods that
9 conveniently drive the process of parsing the request, checking base 9 conveniently drive the process of parsing the request, checking base
10 permissions, gathering common page information, gathering 10 permissions, gathering common page information, gathering
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 else: 856 else:
857 after_login_url = framework_helpers.FormatAbsoluteURL( 857 after_login_url = framework_helpers.FormatAbsoluteURL(
858 mr, urls.ISSUE_ENTRY_AFTER_LOGIN) 858 mr, urls.ISSUE_ENTRY_AFTER_LOGIN)
859 return _SafeCreateLoginURL(mr, after_login_url) 859 return _SafeCreateLoginURL(mr, after_login_url)
860 860
861 861
862 def _SafeCreateLoginURL(mr, continue_url=None): 862 def _SafeCreateLoginURL(mr, continue_url=None):
863 """Make a login URL w/ a detailed continue URL, otherwise use a short one.""" 863 """Make a login URL w/ a detailed continue URL, otherwise use a short one."""
864 continue_url = continue_url or mr.current_page_url 864 continue_url = continue_url or mr.current_page_url
865 try: 865 try:
866 return users.create_login_url(continue_url) 866 url = users.create_login_url(continue_url)
867 except users.RedirectTooLongError: 867 except users.RedirectTooLongError:
868 if mr.project_name: 868 if mr.project_name:
869 return users.create_login_url('/p/%s' % mr.project_name) 869 url = users.create_login_url('/p/%s' % mr.project_name)
870 else: 870 else:
871 return users.create_login_url('/') 871 url = users.create_login_url('/')
872
873 # Give the user a choice of existing accounts in their session
874 # or the option to add an account, even if they are currently
875 # signed in to exactly one account.
876 url = url.replace('/accounts/ServiceLogin', '/a/SelectSession', 1)
877 return url
872 878
873 879
874 def _SafeCreateLogoutURL(mr): 880 def _SafeCreateLogoutURL(mr):
875 """Make a logout URL w/ a detailed continue URL, otherwise use a short one.""" 881 """Make a logout URL w/ a detailed continue URL, otherwise use a short one."""
876 try: 882 try:
877 return users.create_logout_url(mr.current_page_url) 883 return users.create_logout_url(mr.current_page_url)
878 except users.RedirectTooLongError: 884 except users.RedirectTooLongError:
879 if mr.project_name: 885 if mr.project_name:
880 return users.create_logout_url('/p/%s' % mr.project_name) 886 return users.create_logout_url('/p/%s' % mr.project_name)
881 else: 887 else:
882 return users.create_logout_url('/') 888 return users.create_logout_url('/')
883 889
884 890
885 class Error(Exception): 891 class Error(Exception):
886 """Base class for errors from this module.""" 892 """Base class for errors from this module."""
887 pass 893 pass
888 894
889 895
890 class AlreadySentResponseException(Error): 896 class AlreadySentResponseException(Error):
891 """The servlet already responded, no need to render a page template.""" 897 """The servlet already responded, no need to render a page template."""
892 pass 898 pass
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698