Changeset 2750

Show
Ignore:
Timestamp:
11/07/07 08:22:57 (1 year ago)
Author:
dalius
Message:

sreg support + expire time set to 24 hours

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • authopenidplugin/0.11/authopenid/authopenid.py

    r2747 r2750  
    3434 
    3535from openid.consumer import consumer 
     36from openid import sreg 
    3637 
    3738class AuthOpenIdPlugin(Component): 
     
    209210                # communicate securely with the identity server. 
    210211 
     212                sreg_request = sreg.SRegRequest(optional=['nickname', 'email']) 
     213                request.addExtension(sreg_request) 
     214 
    211215                trust_root = self._get_trust_root(req) + '/' 
    212216                return_to = self._get_trust_root(req) + req.href.openidprocess() 
     
    277281            req.outcookie['trac_auth'] = cookie 
    278282            req.outcookie['trac_auth']['path'] = req.href() 
     283            req.outcookie['trac_auth']['expires'] = 60*60*24 
     284 
     285            reg_info = sreg.SRegResponse.fromSuccessResponse(info).getExtensionArgs() 
     286 
     287            if reg_info and reg_info.has_key('nickname') and len(reg_info['nickname']) > 0: 
     288                req.session['name'] = reg_info['nickname'] 
     289            if reg_info and reg_info.has_key('email') and len(reg_info['email']) > 0: 
     290                req.session['email'] = reg_info['email'] 
     291 
    279292        elif info.status == consumer.CANCEL: 
    280293            # cancelled 
     
    326339        cursor = db.cursor() 
    327340        cursor.execute("DELETE FROM auth_cookie WHERE name=%s OR time < %s", 
    328                        (req.authname, int(time.time()) - 86400 * 10)) 
     341                       (req.authname, int(time.time()) - 60*60*24)) 
    329342        db.commit() 
    330343        self._expire_cookie(req)