Skip to content
Browse files

auth layer now basically works

  • Loading branch information...
1 parent 2c60c17 commit 42211ada3e998e5aaa9f85e750feaada3ed8b0ee root committed Sep 8, 2010
Showing with 20 additions and 11 deletions.
  1. +20 −11 godauth/auth.py
View
31 godauth/auth.py
@@ -1,5 +1,3 @@
-import os
-
from trac.core import *
from trac.web.api import IAuthenticator, IRequestFilter
from trac.web.chrome import INavigationContributor
@@ -17,7 +15,7 @@ class GodAuthLoginModule(Component):
def authenticate(self, req):
authname = None
- user = os.getenv("GodAuth_User")
+ user = req.get_header("godauth-user")
if user is not None:
authname = user
@@ -39,9 +37,9 @@ def get_active_navigation_item(self, req):
def get_navigation_items(self, req):
if req.authname and req.authname != 'anonymous':
- yield 'fake', 'fake', 'fake'
+ yield 'metanav', 'login', Markup('<span class="tinylogin">Hello %s</span>' % req.authname)
else:
- yield 'metanav', 'login', Markup('<span class="tinylogin">Log in above to edit stuff</span>')
+ yield 'metanav', 'login', Markup('<span class="tinylogin">Not logged in</span>')
#
@@ -51,10 +49,21 @@ def get_navigation_items(self, req):
def pre_process_request(self, req, handler):
return handler
- def post_process_request(self, req, template, content_type):
- req.hdf.removeTree('chrome.nav.metanav.help')
- req.hdf.removeTree('chrome.nav.metanav.about')
- if not req.authname or req.authname == 'anonymous':
- req.hdf.removeTree('chrome.nav.metanav.settings')
- return template, content_type
+ def post_process_request(self, req, template, data, content_type):
+
+ new_list = []
+ for v in req.chrome['nav']['metanav']:
+ use = True
+ if v['name'] == 'help':
+ use = False
+ if v['name'] == 'about':
+ use = False
+ if not req.authname or req.authname == 'anonymous':
+ if v['name'] == 'settings':
+ use = False
+ if use:
+ new_list.append(v)
+ req.chrome['nav']['metanav'] = new_list
+
+ return template, data, content_type

0 comments on commit 42211ad

Please sign in to comment.
Something went wrong with that request. Please try again.