changeset 6074:6366f5b440ff

use "specific action: failure reason" in log_attempt calls
author 'Karl O. Pinc' <kop@meme.com>
date Mon, 15 Sep 2014 21:27:54 -0500
parents 338348b5d5ad
children 3f7f4cef7c2a
files MoinMoin/PageEditor.py MoinMoin/action/edit.py MoinMoin/action/newpage.py MoinMoin/action/revert.py MoinMoin/wsgiapp.py
diffstat 5 files changed, 20 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Mon Sep 15 21:14:44 2014 -0500
+++ b/MoinMoin/PageEditor.py	Mon Sep 15 21:27:54 2014 -0500
@@ -169,7 +169,8 @@
 
         # check edit permissions
         if not request.user.may.write(self.page_name):
-            log_attempt('edit: edit', False, request, pagename=self.page_name)
+            log_attempt('edit: no permissions', False, request,
+                        pagename=self.page_name)
             msg = _('You are not allowed to edit this page.')
         elif not self.isWritable():
             log_attempt('edit: immutable', False, request,
@@ -555,7 +556,8 @@
             return False, _("You can't copy to an empty pagename.")
 
         if not self.request.user.may.write(newpagename):
-            log_attempt('edit: copy', False, request, pagename=self.page_name)
+            log_attempt('copy: no permissions', False, request,
+                        pagename=self.page_name)
             return False, _('You are not allowed to copy this page!')
 
         newpage = PageEditor(request, newpagename)
@@ -608,7 +610,7 @@
 
         if not (request.user.may.delete(self.page_name)
                 and request.user.may.write(newpagename)):
-            log_attempt('edit: rename', False, request,
+            log_attempt('rename: no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to rename this page!')
             raise self.AccessDenied(msg)
@@ -717,7 +719,7 @@
         success = True
         if not (request.user.may.write(self.page_name)
                 and request.user.may.delete(self.page_name)):
-            log_attempt('edit: delete', False, request,
+            log_attempt('delete: no permissions', False, request,
                         pagename=self.page_name)
             msg = _('You are not allowed to delete this page!')
             raise self.AccessDenied(msg)
@@ -1083,7 +1085,8 @@
 
         msg = ""
         if not request.user.may.save(self, newtext, rev, **kw):
-            log_attempt('edit: edit', False, request, pagename=self.page_name)
+            log_attempt('save: no permissions', False, request,
+                        pagename=self.page_name)
             msg = _('You are not allowed to edit this page!')
             raise self.AccessDenied(msg)
         elif not self.isWritable():
@@ -1132,7 +1135,7 @@
             if (not request.user.may.admin(self.page_name) and
                 parseACL(request, newtext).acl != acl.acl and
                 action != "SAVE/REVERT"):
-                log_attempt('edit: acl', False, request,
+                log_attempt('acl change: no permissions', False, request,
                             pagename=self.page_name)
                 msg = _("You can't change ACLs on this page since you have no admin rights on it!")
                 raise self.NoAdmin(msg)
--- a/MoinMoin/action/edit.py	Mon Sep 15 21:14:44 2014 -0500
+++ b/MoinMoin/action/edit.py	Mon Sep 15 21:27:54 2014 -0500
@@ -23,7 +23,7 @@
         return
 
     if not request.user.may.write(pagename):
-        log_attempt('edit: edit', False, request, pagename=pagename)
+        log_attempt('edit: no permissions', False, request, pagename=pagename)
         page = wikiutil.getLocalizedPage(request, 'PermissionDeniedPage')
         page.body = _('You are not allowed to edit this page.')
         page.page_name = pagename
--- a/MoinMoin/action/newpage.py	Mon Sep 15 21:14:44 2014 -0500
+++ b/MoinMoin/action/newpage.py	Mon Sep 15 21:27:54 2014 -0500
@@ -66,7 +66,8 @@
         page = Page(self.request, self.pagename)
         if not (page.isWritable() and self.request.user.may.read(self.pagename)):
             # Same error as the edit page for localization reasons
-            log_attempt('newpage', False, self.request, pagename=self.pagename)
+            log_attempt('newpage: immutable or no permissions', False,
+                        self.request, pagename=self.pagename)
             return _('You are not allowed to edit this page.')
         return ''
 
--- a/MoinMoin/action/revert.py	Mon Sep 15 21:14:44 2014 -0500
+++ b/MoinMoin/action/revert.py	Mon Sep 15 21:27:54 2014 -0500
@@ -34,7 +34,8 @@
         may = self.request.user.may
         allowed = may.write(self.pagename) and may.revert(self.pagename)
         if not allowed:
-            log_attempt('revert', False, self.request, pagename=self.pagename)
+            log_attempt('revert: immutable or no permissions', False,
+                        self.request, pagename=self.pagename)
         return allowed, _('You are not allowed to revert this page!')
 
     def check_condition(self):
--- a/MoinMoin/wsgiapp.py	Mon Sep 15 21:14:44 2014 -0500
+++ b/MoinMoin/wsgiapp.py	Mon Sep 15 21:27:54 2014 -0500
@@ -174,10 +174,11 @@
         msg = _("You are not allowed to do %(action_name)s on this page.") % {
                 'action_name': wikiutil.escape(action_name), }
         if context.user.valid:
-            log_attempt(action_name, False, request,
+            log_attempt(action_name + ': action unavailable', False, request,
                         context.user.name, pagename=pagename)
         else:
-            log_attempt(action_name, False, request, pagename=pagename)
+            log_attempt(action_name + ': action unavailable', False, request,
+                        pagename=pagename)
             # Suggest non valid user to login
             msg += " " + _("Login and try again.")
 
@@ -192,10 +193,11 @@
             msg = _("You are not allowed to do %(action_name)s on this page.") % {
                     'action_name': wikiutil.escape(action_name), }
             if context.user.valid:
-                log_attempt(action_name, False, request,
+                log_attempt(action_name + ': no handler', False, request,
                             context.user.name, pagename=pagename)
             else:
-                log_attempt(action_name, False, request, pagename=pagename)
+                log_attempt(action_name + ': no handler', False, request,
+                            pagename=pagename)
                 # Suggest non valid user to login
                 msg += " " + _("Login and try again.")
             context.theme.add_msg(msg, "error")