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

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

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 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
OLDNEW
(Empty)
1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is govered by a BSD-style
3 # license that can be found in the LICENSE file or at
4 # https://developers.google.com/open-source/licenses/bsd
5
6 """A class to display the a message explaining that the user has been banned.
7
8 We can ban a user for anti-social behavior. We indicate that the user is
9 banned by adding a 'banned' field to his/her User PB in the DB. Whenever
10 a user with a banned indicator visits any page, AssertBasePermission()
11 checks has_banned and redirects to this page.
12 """
13
14 import logging
15
16 from framework import permissions
17 from framework import servlet
18
19
20 class Banned(servlet.Servlet):
21 """The Banned page shows a message explaining that the user is banned."""
22
23 _PAGE_TEMPLATE = 'framework/banned-page.ezt'
24
25 def AssertBasePermission(self, mr):
26 """Allow banned users to see this page, and prevent non-banned users."""
27 # Note, we do not call Servlet.AssertBasePermission because
28 # that would redirect banned users here again in an endless loop.
29
30 # We only show this page to users who are banned. If a non-banned user
31 # follows a link to this URL, don't show the banned message, because that
32 # would lead to a big misunderstanding.
33 if not permissions.IsBanned(mr.auth.user_pb, mr.auth.user_view):
34 logging.info('non-banned user: %s', mr.auth.user_pb)
35 self.abort(404)
36
37 def GatherPageData(self, _mr):
38 """Build up a dictionary of data values to use when rendering the page."""
39 return {
40 # We do not actually display the specific reason for banning.
41 # That info is available via command-line tools..
42
43 # Make the "Sign Out" link just sign out, don't try to bring the
44 # user back to this page after they sign out.
45 'currentPageURLEncoded': None,
46 }
OLDNEW
« no previous file with comments | « appengine/monorail/framework/artifactcollision.py ('k') | appengine/monorail/framework/captcha.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698