handle register with email adress
authorArthur Lutz <arthur.lutz@logilab.fr>
Mon, 16 Feb 2009 19:53:35 +0100
changeset 636 3e9245cf0d9c
parent 626 97924df9168c
child 637 a78ffe83fadc
handle register with email adress
server/repository.py
--- a/server/repository.py	Mon Feb 16 15:21:46 2009 +0100
+++ b/server/repository.py	Mon Feb 16 19:53:35 2009 +0100
@@ -491,6 +491,9 @@
         try:
             if session.execute('EUser X WHERE X login %(login)s', {'login': login}):
                 return False
+            if session.execute('EUser X WHERE X use_email C, C address %(login)s',
+                               {'login': login}):
+                return False
             # we have to create the user
             user = self.vreg.etype_class('EUser')(session, None)
             if isinstance(password, unicode):
@@ -502,6 +505,11 @@
             self.glob_add_entity(session, user)
             session.execute('SET X in_group G WHERE X eid %(x)s, G name "users"',
                             {'x': user.eid})
+            # FIXME this does not work yet
+            if '@' in login:
+                session.execute('INSERT EmailAddress X: X address "%(login)s", '
+                                'U primary_email X, U use_email X WHERE U login "%(login)s"',
+                                {'login':login})
             session.commit()
         finally:
             session.close()