def create_user(self, email, password):
     try:
         if User.validate(email, password):
             password, salt = User.create_pass(password)
         if salt:
             user = self.users_gateway.create(email=email,
                                              password=password,
                                              salt=salt)
         if user:
             create_cookie(SESSION_NAME, user)
     except Exception as e:
         raise e
     return user
Esempio n. 2
0
 def test_validation_with_less_characters(self):
     user = User(email="*****@*****.**", password="******")
     with self.assertRaises(Exception):
         user.validate(user.email, user.password)
Esempio n. 3
0
 def test_validation_with_wrong_mail_no_dotself(self):
     user = User(email="ppp@abvbg", password="******")
     with self.assertRaises(Exception):
         user.validate(user.email, user.password)
Esempio n. 4
0
 def test_validation_with_worng_mail_no_nokey_a(self):
     user = User(email="pppabv.bg", password="******")
     with self.assertRaises(Exception):
         user.validate(user.email, user.password)
Esempio n. 5
0
 def test_validation_with_8_characters_but_no_capital_has_special(self):
     user = User(email="*****@*****.**", password="******")
     with self.assertRaises(Exception):
         user.validate(user.email, user.password)
 def create(self, session, *, email, password, salt):
     try:
         session.add(User(email=email, password=password, salt=salt))
         return email
     except Exception as e:
         return e