comparison contrib/auth_externalcookie/wikiconfig.py @ 300:174cba552bd9

Fixed a few copy & paste bugs. imported from: moin--main--1.5--patch-304
author Alexander Schremmer <alex@alexanderweb.de.tla>
date Thu, 08 Dec 2005 20:04:35 +0000
parents 91d47ebee530
children ad642b8d5fec
comparison
equal deleted inserted replaced
299:da111ed329ee 300:174cba552bd9
9 class FarmConfig(DefaultConfig): 9 class FarmConfig(DefaultConfig):
10 def external_cookie(request, **kw): 10 def external_cookie(request, **kw):
11 """ authenticate via external cookie """ 11 """ authenticate via external cookie """
12 import Cookie 12 import Cookie
13 user = None 13 user = None
14 try_next = True # if True, moin tries the next auth method
14 cookiename = "whatever" # XXX external cookie name you want to use 15 cookiename = "whatever" # XXX external cookie name you want to use
16
15 try: 17 try:
16 cookie = Cookie.SimpleCookie(request.saved_cookie) 18 cookie = Cookie.SimpleCookie(request.saved_cookie)
17 except Cookie.CookieError: 19 except Cookie.CookieError:
18 # ignore invalid cookies 20 # ignore invalid cookies
19 cookie = None 21 cookie = None
47 if aliasname != user.aliasname: # was the aliasname externally updated? 49 if aliasname != user.aliasname: # was the aliasname externally updated?
48 user.aliasname = aliasname ; changed = True # yes -> update user profile 50 user.aliasname = aliasname ; changed = True # yes -> update user profile
49 if email != user.email: # was the email addr externally updated? 51 if email != user.email: # was the email addr externally updated?
50 user.email = email ; changed = True # yes -> update user profile 52 user.email = email ; changed = True # yes -> update user profile
51 53
52 if u: 54 if user:
53 u.create_or_update(changed) 55 user.create_or_update(changed)
54 if u and u.valid: # did we succeed making up a valid user? 56 if user and user.valid: # did we succeed making up a valid user?
55 return u, False # yes, return user object and stop processing auth method list 57 try_next = False # stop processing auth method list
56 return None, True # no, return None and continue with next method in auth list 58 return user, try_next
57 59
58 from MoinMoin.auth import moin_cookie, http 60 from MoinMoin.auth import moin_cookie, http
59 # first try the external_cookie, then http basic auth, then the usual moin_cookie 61 # first try the external_cookie, then http basic auth, then the usual moin_cookie
60 auth = [external_cookie, http, moin_cookie] 62 auth = [external_cookie, http, moin_cookie]
61 63