Esempio n. 1
0
    def test_user_hash(self):
        reload(utils)

        phone = "fakephone"
        device = "fakedevice"

        hashed = utils.user_hash(phone, device)

        self.assertTrue(str.isalnum(hashed))
        self.assertEqual(len(hashed), 56)
Esempio n. 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(result)
                return
            AuthDB.create_user(phone, hashed, create_callback)

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