web/views/authentication.py
branchtls-sprint
changeset 1690 e4f7d2ddc99a
parent 1668 d2ac1d681d70
parent 1664 03ebeccf9f1d
child 1977 606923dff11b
equal deleted inserted replaced
1689:7ff9f0726ee4 1690:e4f7d2ddc99a
    51         # associate the connection to the current request
    51         # associate the connection to the current request
    52         req.set_connection(cnx, user)
    52         req.set_connection(cnx, user)
    53         return cnx
    53         return cnx
    54 
    54 
    55     def login_from_email(self, login):
    55     def login_from_email(self, login):
       
    56         # XXX should not be called from web interface
    56         session = self.repo.internal_session()
    57         session = self.repo.internal_session()
    57         rset = session.execute('Any L WHERE U login L, U primary_email M, '
    58         try:
    58                                'M address %(login)s', {'login': login})
    59             rset = session.execute('Any L WHERE U login L, U primary_email M, '
    59         if rset.rowcount == 1:
    60                                    'M address %(login)s', {'login': login})
    60             login = rset[0][0]
    61             if rset.rowcount == 1:
       
    62                 login = rset[0][0]
       
    63         finally:
       
    64             session.close()
    61         return login
    65         return login
    62 
    66 
    63     def authenticate(self, req, _login=None, _password=None):
    67     def authenticate(self, req, _login=None, _password=None):
    64         """authenticate user and return corresponding user object
    68         """authenticate user and return corresponding user object
    65 
    69