From 30e32c07b94627ff36d14fd0cbccfaed8fa01f9b Mon Sep 17 00:00:00 2001 From: mdipierro Date: Tue, 8 Jan 2013 08:58:30 -0600 Subject: [PATCH] fixed issue 1252, thanks Mark Weissen --- VERSION | 2 +- gluon/contrib/login_methods/openid_auth.py | 29 ++++++++++++---------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/VERSION b/VERSION index 359d305c..6efa1366 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.4.1-alpha.2+timestamp.2013.01.08.08.48.34 +Version 2.4.1-alpha.2+timestamp.2013.01.08.08.57.51 diff --git a/gluon/contrib/login_methods/openid_auth.py b/gluon/contrib/login_methods/openid_auth.py index 4e977030..0c763e81 100644 --- a/gluon/contrib/login_methods/openid_auth.py +++ b/gluon/contrib/login_methods/openid_auth.py @@ -129,18 +129,21 @@ class OpenIDAuth(object): def _define_alt_login_table(self): """ Define the OpenID login table. - Note: type is what I used for our project. We're going to support 'fackbook' and - 'plurk' alternate login methods. Otherwise it's always 'openid' and you + Note: oidtype is what I used for our project. + We're going to support 'fackbook' and + 'plurk' alternate login methods. + Otherwise it's always 'openid' and you may not need it. This should be easy to changed. (Just remove the field of "type" and remove the - "and db.alt_logins.type == type_" in _find_matched_openid function) + "and db.alt_logins.oidtype == type_" + in _find_matched_openid function) """ db = self.db table = db.define_table( self.table_alt_logins_name, Field('username', length=512, default=''), - Field('type', length=128, default='openid', readable=False), - Field('user', self.table_user, readable=False), + Field('oidtype', length=128, default='openid', readable=False), + Field('oiduser', self.table_user, readable=False), ) table.username.requires = IS_NOT_IN_DB(db, table.username) self.table_alt_logins = table @@ -213,7 +216,7 @@ class OpenIDAuth(object): # Get existed OpenID user user = db( - self.table_user.id == alt_login.user).select().first() + self.table_user.id == alt_login.oiduser).select().first() if user: if current.session.w2popenid: del(current.session.w2popenid) @@ -230,7 +233,7 @@ class OpenIDAuth(object): Get the matched OpenID for given """ query = ( - (db.alt_logins.username == oid) & (db.alt_logins.type == type_)) + (db.alt_logins.username == oid) & (db.alt_logins.oidtype == type_)) alt_login = db(query).select().first() # Get the OpenID record return alt_login @@ -239,7 +242,7 @@ class OpenIDAuth(object): Associate the user logged in with given OpenID """ # print "[DB] %s authenticated" % oid - self.db.alt_logins.insert(username=oid, user=user.id) + self.db.alt_logins.insert(username=oid, oiduser=user.id) def _form_with_notification(self): """ @@ -400,7 +403,7 @@ width: 400px; if 'delete_openid' in request.vars: self.remove_openid(request.vars.delete_openid) - query = self.db.alt_logins.user == self.auth.user.id + query = self.db.alt_logins.oiduser == self.auth.user.id alt_logins = self.db(query).select() l = [] for alt_login in alt_logins: @@ -529,7 +532,7 @@ class Web2pyStore(OpenIDStore): self.database.define_table(self.table_oid_nonces_name, Field('server_url', 'string', length=2047, required=True), - Field('timestamp', + Field('itimestamp', 'integer', required=True), Field('salt', 'string', length=40, required=True) @@ -591,12 +594,12 @@ class Web2pyStore(OpenIDStore): db = self.database if abs(timestamp - time.time()) > nonce.SKEW: return False - query = (db.oid_nonces.server_url == server_url) & (db.oid_nonces.timestamp == timestamp) & (db.oid_nonces.salt == salt) + query = (db.oid_nonces.server_url == server_url) & (db.oid_nonces.itimestamp == timestamp) & (db.oid_nonces.salt == salt) if db(query).count() > 0: return False else: db.oid_nonces.insert(server_url=server_url, - timestamp=timestamp, + itimestamp=timestamp, salt=salt) return True @@ -628,7 +631,7 @@ class Web2pyStore(OpenIDStore): """ db = self.database - query = (db.oid_nonces.timestamp < time.time() - nonce.SKEW) + query = (db.oid_nonces.itimestamp < time.time() - nonce.SKEW) return db(query).delete() def cleanupAssociations(self):