cubicweb/repoapi.py
changeset 12044 70bb46dfa87b
parent 12032 c16c1805e973
child 12046 9056a41d91ba
--- a/cubicweb/repoapi.py	Tue Mar 14 11:07:58 2017 +0100
+++ b/cubicweb/repoapi.py	Fri Mar 10 18:04:25 2017 +0100
@@ -45,8 +45,13 @@
 def connect(repo, login, **kwargs):
     """Take credential and return associated Connection.
 
-    raise AuthenticationError if the credential are invalid."""
-    return repo.new_session(login, **kwargs).new_cnx()
+    raise AuthenticationError if the credential are invalid.
+    """
+    # use an internal connection to try to get a user object
+    with repo.internal_cnx() as cnx:
+        user = repo.authenticate_user(cnx, login, **kwargs)
+    return Connection(repo, user)
+
 
 def anonymous_cnx(repo):
     """return a Connection for Anonymous user.