OLD | NEW |
(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 } |
OLD | NEW |