[server/sources] Fix authenticate on pre-3.10 database
authorJulien Cristau <julien.cristau@logilab.fr>
Mon, 07 Mar 2016 17:53:20 +0100
changeset 11177 8448a8c5cca4
parent 11121 79b124ec1157
child 11178 b3d3e23be27b
[server/sources] Fix authenticate on pre-3.10 database When migrating from a pre-3.10 database, the CWSource entity type and cw_source relation type are not known, but authenticate should still work to be able to add them.
server/sources/native.py
--- a/server/sources/native.py	Tue Feb 16 18:17:35 2016 +0100
+++ b/server/sources/native.py	Mon Mar 07 17:53:20 2016 +0100
@@ -1486,7 +1486,12 @@
         if 'CWUser' in schema: # probably an empty schema if not true...
             # rql syntax trees used to authenticate users
             self._passwd_rqlst = self.source.compile_rql(self.passwd_rql, self._sols)
-            self._auth_rqlst = self.source.compile_rql(self.auth_rql, self._sols)
+            if 'CWSource' in schema:
+                self._auth_rqlst = self.source.compile_rql(self.auth_rql, self._sols)
+            else:
+                self._auth_rqlst = self.source.compile_rql(
+                        u'Any X WHERE X is CWUser, X login %(login)s, X upassword %(pwd)s',
+                        ({'X': 'CWUser', 'P': 'Password'},))
 
     def authenticate(self, cnx, login, password=None, **kwargs):
         """return CWUser eid for the given login/password if this account is