Exemplo n.º 1
0
    def post(self):
        pnum = self.post_data.get('pnum', '')
        password = self.post_data.get('password', '')
        uid = self.post_data.get('uid', '')
        user_name = self.post_data.get('user_name', '')
        password = self.get_password(password)

        res = yield UserLib.get_user_by_pnum(pnum)
        if res:
            self.writeS({"data": "This pnum have been registered"})
            return
        user_info = yield UserLib.create_user(uid, pnum, user_name, password)
        if user_info:
            self.writeS({"data": user_info, "code": 0})
            return
        self.writeS({})
        return
 def create_userlist_pkg(self):
     users = []
     for c in NAMED_CONNECTED_CLIENTS.values():
         user_info = yield UserLib.get_user_by_uid(c.uid)
         pnum = user_info.get("pnum", '')
         users.append({'name': c.client_name, 'uid': c.uid, 'pnum': pnum});
     pkgdata = {'TYPE': USERLIST, 'USERS': users}
     raise gen.Return(json.dumps(pkgdata))
Exemplo n.º 3
0
    def post(self):
        pnum = self.post_data.get("pnum", "")
        password = self.post_data.get("password", "")
        uid = self.post_data.get("uid", "")
        user_name = self.post_data.get("user_name", "")
        password = self.get_password(password)

        res = yield UserLib.get_user_by_pnum(pnum)
        if res:
            self.writeS({"data": "This pnum have been registered"})
            return
        user_info = yield UserLib.create_user(uid, pnum, user_name, password)
        if user_info:
            self.writeS({"data": user_info, "code": 0})
            return
        self.writeS({})
        return
 def create_userlist_pkg(self):
     users = []
     for c in NAMED_CONNECTED_CLIENTS.values():
         user_info = yield UserLib.get_user_by_uid(c.uid)
         pnum = user_info.get("pnum", '')
         users.append({
             'name': c.client_name,
             'uid': c.uid,
             'pnum': pnum
         })
     pkgdata = {'TYPE': USERLIST, 'USERS': users}
     raise gen.Return(json.dumps(pkgdata))
Exemplo n.º 5
0
 def get(self):
     pnum = self.post_data.get("pnum", "")
     password = self.post_data.get("password", "")
     user_info = yield UserLib.get_user_by_pnum(pnum)
     if user_info and user_info.get("password", 0) == self.get_password(password):
         self.writeS({"data": user_info, "code": 0})
         return
     elif user_info:
         self.writeS({"data": "Error login info !!", "code": 1})
         return
     self.writeS({"data": "Phone number not registered", "code": 2})
     return
    def get(self):
        uid = self.post_data.get('uid', '')
        password = self.post_data.get('password', '')
        last_msg_id = self.post_data.get('last_msg_id', '')

        res = yield UserLib.check_user(uid, password)
        if res:
            message_history = yield MessageLib.get_message_history(uid, last_msg_id)
            self.writeS({"data": message_history, "code": 0})
        else:
            self.writeS({"data": "Error login info !!", "code": 1})
            return
Exemplo n.º 7
0
 def get(self):
     pnum = self.post_data.get('pnum', '')
     password = self.post_data.get('password', '')
     user_info = yield UserLib.get_user_by_pnum(pnum)
     if user_info and user_info.get('password',
                                    0) == self.get_password(password):
         self.writeS({"data": user_info, "code": 0})
         return
     elif user_info:
         self.writeS({"data": "Error login info !!", "code": 1})
         return
     self.writeS({"data": "Phone number not registered", "code": 2})
     return
    def get(self):
        uid = self.post_data.get('uid', '')
        password = self.post_data.get('password', '')
        last_msg_id = self.post_data.get('last_msg_id', '')

        res = yield UserLib.check_user(uid, password)
        if res:
            message_history = yield MessageLib.get_message_history(
                uid, last_msg_id)
            self.writeS({"data": message_history, "code": 0})
        else:
            self.writeS({"data": "Error login info !!", "code": 1})
            return
Exemplo n.º 9
0
def _test_add_user():
    return loop.run_until_complete(UserLib.add_user({
                                                    'reg_qid': int('135' + str(random.randint(10000000, 99999999))),
                                                    'token': 'access_token',
                                                    'reg_source': 'mb',
                                                    'invite_uid': '10000000',
                                                    'reg_ip': '127.0.0.1',
                                                    'os_type': 'ios',
                                                    'device_id': 'fake_device_id_12345678',
                                                    'app_version': '1.0.0.0',
                                                    'channel': 'test',
                                                    'package_name': 'com.test.com',
                                                    'nickname': 'nickname',
                                                    'gender': 'M',
                                                    'figure_url': 'http://img.zcool.cn/community/0122e655f8f3e06ac7251df8686c5f.png',
                                                    'figure_url_other': 'http://img.zcool.cn/community/0122e655f8f3e06ac7251df8686c5f.png',
                                                    'province': 'province',
                                                    'city': 'city',
                                                    'country': 'country',
                                                    'year': 1988,
                                                    }))
Exemplo n.º 10
0
def test_get_user_by_uid():
    assert loop.run_until_complete(UserLib.get_user_info_by_uid(10000000))['uid'] == 10000000
    assert not loop.run_until_complete(UserLib.get_user_info_by_uid(90000000))