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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/monorail/framework/artifactcollision.py ('k') | appengine/monorail/framework/captcha.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/monorail/framework/banned.py
diff --git a/appengine/monorail/framework/banned.py b/appengine/monorail/framework/banned.py
new file mode 100644
index 0000000000000000000000000000000000000000..45dd326bbc88165230e8e38be18cd79e828a69c7
--- /dev/null
+++ b/appengine/monorail/framework/banned.py
@@ -0,0 +1,46 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""A class to display the a message explaining that the user has been banned.
+
+We can ban a user for anti-social behavior. We indicate that the user is
+banned by adding a 'banned' field to his/her User PB in the DB. Whenever
+a user with a banned indicator visits any page, AssertBasePermission()
+checks has_banned and redirects to this page.
+"""
+
+import logging
+
+from framework import permissions
+from framework import servlet
+
+
+class Banned(servlet.Servlet):
+ """The Banned page shows a message explaining that the user is banned."""
+
+ _PAGE_TEMPLATE = 'framework/banned-page.ezt'
+
+ def AssertBasePermission(self, mr):
+ """Allow banned users to see this page, and prevent non-banned users."""
+ # Note, we do not call Servlet.AssertBasePermission because
+ # that would redirect banned users here again in an endless loop.
+
+ # We only show this page to users who are banned. If a non-banned user
+ # follows a link to this URL, don't show the banned message, because that
+ # would lead to a big misunderstanding.
+ if not permissions.IsBanned(mr.auth.user_pb, mr.auth.user_view):
+ logging.info('non-banned user: %s', mr.auth.user_pb)
+ self.abort(404)
+
+ def GatherPageData(self, _mr):
+ """Build up a dictionary of data values to use when rendering the page."""
+ return {
+ # We do not actually display the specific reason for banning.
+ # That info is available via command-line tools..
+
+ # Make the "Sign Out" link just sign out, don't try to bring the
+ # user back to this page after they sign out.
+ 'currentPageURLEncoded': None,
+ }
« 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