server/repository.py
changeset 636 3e9245cf0d9c
parent 594 76218d42d21f
child 1016 26387b836099
--- 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()