Exemplo n.º 1
0
def auth(username, password):
    '''
    验证数据正确性
    :param username: 用户名
    :param password:  密码
    :return:
    '''
    data = {}
    usersdata = load_dump_data.load_data()
    if username in usersdata and password == usersdata[username]['password']:
        data[username] = usersdata[username]
        return data
Exemplo n.º 2
0
    def _auth(self, res):
        """验证数据正确性"""

        username = res['username']
        password = res['password']
        data = {}
        usersdata = load_dump_data.load_data()
        if username in usersdata and password == usersdata[username]['password']:
            data[username] = usersdata[username]  # 组成新的键值对
            self.user = data
            self.path = os.path.join(self.base_path, self.user[username]['home'])
            self.current_dir = self.path
            os.chdir(self.path)
            self.conn.send(b'100')  # 登录成功
            self.logobj.info('client  %s connect and user %s logined' % (str(self.addr), username))
        else:
            self.conn.send(b'101')  # 登录失败