changeset 1336:e9fe4ff57cbb beta

Do a redirect to login for anonymous users
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 15 May 2011 13:49:14 +0200
parents 40c8d18102a9
children 37625d304a16
files rhodecode/lib/auth.py
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/auth.py	Sun May 15 13:20:07 2011 +0200
+++ b/rhodecode/lib/auth.py	Sun May 15 13:49:14 2011 +0200
@@ -410,8 +410,22 @@
 
         else:
             log.warning('Permission denied for %s %s', cls, self.user)
-            #redirect with forbidden ret code
-            return abort(403)
+
+
+            anonymous = self.user.username == 'default'
+
+            if anonymous:
+                p = url.current()
+
+                import rhodecode.lib.helpers as h
+                h.flash(_('You need to be a signed in to '
+                          'view this page'),
+                        category='warning')
+                return redirect(url('login_home', came_from=p))
+
+            else:
+                #redirect with forbidden ret code
+                return abort(403)
 
     def check_permissions(self):
         """Dummy function for overriding"""