Details

Applies to
1.6.1 - 1.8
Purpose
To automatically fill in the "email" section in the user's preferences if the "email" field is ever empty.
Description
The email section won't be overridden if the user has specified a email address. The introduced code path runs only if the email field is empty (eg on account creation or user accidentally set their email address to blank). To activate, apply patch, then set "auth_http_save_email = True" and "auth_http_email_suffix = '@somedomain.com'" in wikiconfig.py. If you set "auth_http_save_email" to True but do not set "auth_http_email_suffix", it will leave the email field blank.

For example, if you set "auth_http_email_suffix = '@blah.com'", and the user 'joeschmoe' logs in, his email attribute will be automatically filled in as 'joeschmoe@blah.com'.

Patch

   1 --- multiconfig.py.org	2008-02-20 13:59:16.000000000 -0800
   2 +++ multiconfig.py	2008-02-20 13:40:48.000000000 -0800
   3 @@ -201,6 +201,8 @@ class DefaultConfig:
   4      antispam_master_url = "http://master.moinmo.in/?action=xmlrpc2"
   5      attachments = None # {'dir': path, 'url': url-prefix}
   6      auth = [authmodule.moin_login, authmodule.moin_session, ]
   7 +    auth_http_save_email = False
   8 +    auth_http_email_suffix = ''
   9  
  10      backup_compression = 'gz'
  11      backup_users = []
multiconfig.py.authbasic.patch

//Lib/site-packages/!MoinMoin/auth/http.py

   1 --- http.py.org	2008-02-20 13:53:50.000000000 -0800
   2 +++ http.py	2008-02-20 13:38:21.000000000 -0800
   3 @@ -16,6 +16,7 @@ def http(request, **kw):
   4      """ authenticate via http basic/digest/ntlm auth """
   5      user_obj = kw.get('user_obj')
   6      u = None
   7 +    cfg = request.cfg
   8      # check if we are running Twisted
   9      if isinstance(request, request_twisted.Request):
  10          username = request.twistd.getUser().decode(config.charset)
  11 @@ -43,6 +44,9 @@ def http(request, **kw):
  12              # we don't use the moin user profile for those attributes.
  13              u = user.User(request, auth_username=username,
  14                            auth_method='http', auth_attribs=('name', 'password'))
  15 +            if cfg.auth_http_save_email and cfg.auth_http_email_suffix and u.email == '':
  16 +                email = username + cfg.auth_http_email_suffix
  17 +                u.email = email
  18  
  19      if u:
  20          u.create_or_update()
http.py.authbasic.patch
Note
For Moin versions 1.7 and 1.8, the above patch needs to be pasted in starting at line 85.

Discussion

and it does make sense to disable or remove some form fields in wikiconfig too

user_form_disable = ['name']
user_form_remove = ['password', 'password2', ]

Hmm, that code could be useful independent of the auth method (maybe not for ldap, where the email should come from ldap), but for many others.

So please check if that code could be move to a separate email_is_login auth method to be of general usefulness.

If course this stuff is only usefull if wiki email == fn(login_name).

Plan


CategoryMoinMoinPatch

MoinMoin: MoinMoinPatch/HttpAuthAutoEmail (last edited 2008-10-15 20:51:31 by RickVanderveer)