Changeset 169

Show
Ignore:
Timestamp:
12/29/08 13:18:08 (1 year ago)
Author:
bettse
Message:

re #2850
This uses the already available SSO user info to fill in the user's name and email address anytime they autenticate to a project

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trac-plugins/accountmanagerplugin/trunk/acct_mgr/web_ui.py

    r61 r169  
    2626from trac.util import Markup 
    2727from trac.util.html import html, escape 
     28from trac.web.session import Session 
    2829 
    2930from api import AccountManager 
     
    390391        user = mysso.getsessionuserinfo(req.incookie[self.sso_cookie].value) 
    391392        if user: 
     393 
     394            #This code is based on the commented out code in _create_user. 
     395            #Creating a Session object and doing a save() on it would have been more elegant but didn't seem to work 
     396            req.args['name'] = user['userinfo']['firstname'] + ' ' + user['userinfo']['lastname'] 
     397            req.args['email'] = user['userinfo']['email'] 
     398 
     399            db = self.env.get_db_cnx() 
     400            cursor = db.cursor() 
     401 
     402            for key in ('name', 'email'): 
     403                value = req.args.get(key) 
     404                if not value: 
     405                    continue  
     406                cursor.execute("UPDATE session_attribute SET value=%s " 
     407                               "WHERE name=%s AND sid=%s AND authenticated=1", 
     408                               (value, key, user['userinfo']['username'] )) 
     409                if not cursor.rowcount: 
     410                    cursor.execute("INSERT INTO session_attribute " 
     411                                   "(sid,authenticated,name,value) " 
     412                                   "VALUES (%s,1,%s,%s)", 
     413                                   (user['userinfo']['username'] , key, value)) 
     414            db.commit() 
     415            self.log.info("New session saved for user %s" % req.args['name'] ) 
     416         
     417         
     418         
    392419            req.environ['REMOTE_USER'] = user['userinfo']['username'] 
    393420            return req.environ['REMOTE_USER'] 
  • trac-plugins/accountmanagerplugin/trunk/setup.py

    r46 r169  
    55setup( 
    66    name = 'TracAccountManager', 
    7     version = '0.1.3', 
    8     author = 'Matthew Good', 
    9     author_email = 'trac@matt-good.net', 
     7    version = '0.2.3', 
     8    author = 'Matthew Good, Jose Cedeno, Eric Betts', 
     9    author_email = 'code@lists.oregonstate.edu', 
    1010    url = 'http://trac-hacks.org/wiki/AccountManagerPlugin', 
    11     description = 'User account management plugin for Trac', 
     11    description = 'User account management plugin for Trac with support for OSU SSO', 
    1212 
    1313    license = '''