Пример #1
0
 def post(self):
   data = postData()
   if 'nickname' in data.keys() and 'email' in data.keys() and 'password' in data.keys():
     from util.password import hash_password
     password= hash_password(data['password'])
     return doIt(insertUser(nickname=data['nickname'],email=data['email'], password=password) )
     #return doIt(insertUser(nickname=data['nickname'],email=data['email'], password=data['password']) )
   else:  return json.dumps({"status":"fail1"})
Пример #2
0
 def _add_user_hard(self, username, password):
     # type: (unicode, unicode) -> User
     points = 0
     empty_buf = buffer(intbitset().fastdump())
     self.db.cursor.execute(
         'INSERT INTO users VALUES (NULL, ?, ?, ?, ?, ?)',
         [username,
          hash_password(password), points, empty_buf, empty_buf])
     user_id = self.db.cursor.lastrowid
     self.commit()
     return User(user_id, username, points, intbitset(), intbitset())
Пример #3
0
 def update_password(self, user, password):
     # type: (User, unicode) -> None
     """Update password to `password` for `user`."""
     self.db.cursor.execute('UPDATE users SET password = ? WHERE id = ?',
                            [hash_password(password), user.id])
     self.commit()
Пример #4
0
 def test_check_password_correct(self):
     self.assertTrue(check_password("password", hash_password("password")))
Пример #5
0
 def test_hash_password(self):
     self.assertNotEqual("password", hash_password("password"))
Пример #6
0
 def test_check_password_incorrect(self):
     self.assertFalse(
         check_password("not_password", hash_password("password")))
Пример #7
0
 def update_password(self, new_password):
     self.password = hash_password(new_password)
Пример #8
0
 def __init__(self, email, password):
     self.email = email
     self.password = hash_password(password)