Пример #1
0
    def test_user_hash(self):
        phone = "fakephone"
        device = "fakedevice"

        hashed = user_hash(phone, device)

        self.assertTrue(str.isalnum(hashed))
        self.assertEqual(len(hashed), 56)
Пример #2
0
    def login(self, phone, device):
        @mongo_callback(self)
        def create_callback(result):
            self.respond({
                "_id": result,
                "phone": phone,
            })

        @mongo_callback(self)
        def find_callback(result):
            if result:
                self.respond({
                    "_id": result["_id"],
                    "phone": result["phone"]
                })
                return
            UserDB.create_user(phone, hashed, create_callback)

        hashed = user_hash(phone, device)
        UserDB.find_user_id(hashed, find_callback)