comparison MoinMoin/auth/php_session.py @ 948:28ea5b3802b1

whitespace-only cleanup
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Mon, 17 Jul 2006 03:43:33 +0200
parents ab9cd47eb066
children 9406e02388cf
comparison
equal deleted inserted replaced
947:41f6f7708466 948:28ea5b3802b1
22 """ @param apps: A list of the enabled applications. See above for 22 """ @param apps: A list of the enabled applications. See above for
23 possible keys. 23 possible keys.
24 @param s_path: The path where the PHP sessions are stored. 24 @param s_path: The path where the PHP sessions are stored.
25 @param s_prefix: The prefix of the session files. 25 @param s_prefix: The prefix of the session files.
26 """ 26 """
27 27
28 self.s_path = s_path 28 self.s_path = s_path
29 self.s_prefix = s_prefix 29 self.s_prefix = s_prefix
30 self.apps = apps 30 self.apps = apps
31 31
32 def __call__(self, request, **kw): 32 def __call__(self, request, **kw):
33 def handle_egroupware(session): 33 def handle_egroupware(session):
34 """ Extracts name, fullname and email from the session. """ 34 """ Extracts name, fullname and email from the session. """
35 username = session['egw_session']['session_lid'].split("@", 1)[0] 35 username = session['egw_session']['session_lid'].split("@", 1)[0]
36 known_accounts = session['egw_info_cache']['accounts']['cache']['account_data'] 36 known_accounts = session['egw_info_cache']['accounts']['cache']['account_data']
37 37
38 # if the next line breaks, then the cache was not filled with the current 38 # if the next line breaks, then the cache was not filled with the current
39 # user information 39 # user information
40 user_info = [value for key, value in known_accounts.items() 40 user_info = [value for key, value in known_accounts.items()
41 if value['account_lid'] == username][0] 41 if value['account_lid'] == username][0]
42 name = user_info.get('fullname', '') 42 name = user_info.get('fullname', '')
43 email = user_info.get('email', '') 43 email = user_info.get('email', '')
44 44
45 dec = lambda x: x and x.decode("iso-8859-1") 45 dec = lambda x: x and x.decode("iso-8859-1")
46 46
47 return dec(username), dec(email), dec(name) 47 return dec(username), dec(email), dec(name)
48 48
49 user_obj = kw.get('user_obj') 49 user_obj = kw.get('user_obj')
50 try: 50 try:
51 cookie = Cookie.SimpleCookie(request.saved_cookie) 51 cookie = Cookie.SimpleCookie(request.saved_cookie)
52 except Cookie.CookieError: # ignore invalid cookies 52 except Cookie.CookieError: # ignore invalid cookies
53 cookie = None 53 cookie = None
59 if "egw" in self.apps and session.get('egw_session', None): 59 if "egw" in self.apps and session.get('egw_session', None):
60 username, email, name = handle_egroupware(session) 60 username, email, name = handle_egroupware(session)
61 break 61 break
62 else: 62 else:
63 return user_obj, True 63 return user_obj, True
64 64
65 user = user.User(request, name=username, auth_username=username) 65 user = user.User(request, name=username, auth_username=username)
66 66
67 changed = False 67 changed = False
68 if name != user.aliasname: 68 if name != user.aliasname:
69 user.aliasname = name 69 user.aliasname = name
70 changed = True 70 changed = True
71 if email != user.email: 71 if email != user.email:
72 user.email = email 72 user.email = email
73 changed = True 73 changed = True
74 74
75 if user: 75 if user:
76 user.create_or_update(changed) 76 user.create_or_update(changed)
77 if user and user.valid: 77 if user and user.valid:
78 return user, True # True to get other methods called, too 78 return user, True # True to get other methods called, too
79 return user_obj, True # continue with next method in auth list 79 return user_obj, True # continue with next method in auth list