Beispiel #1
0
 def init_db_users(self):
     _db_file = os.path.join(my_conf.DATABASE['dbpath'], 'users.db')
     for k, v in self._user_dic.items():
         temppasswd = self._user_dic[k]['password']
         encryptpasswd = my_Common.encrypt(temppasswd)
         self._user_dic[k]['password'] = encryptpasswd
     my_jsonhelper.write_db_simplejson(self._user_dic, _db_file)
     print("Table create successfull".format(_db_file))
Beispiel #2
0
 def create_user(self):
     """
     新创建一个用户,将用户数据同步写入到数据库文件
     :return:
     """
     self.dict_user[self.username] = dict(password=my_Common.encrypt(self.password),
                                          name=self.name,
                                          mobile=self.mobile,
                                          # bindcard=self.bindcard,
                                          role=self.role,
                                          islocked=0,
                                          isdel=0,
                                          )
     my_jsonhelper.write_db_simplejson(self.dict_user, self.__database)
Beispiel #3
0
 def update_user(self):
     """
     用户数据更新方法,用户修改信息、用户账户锁定、解锁等操作之后更新数据库文件
     :return:
     """
     try:
         '''
         _password = my_Common.encrypt(self.password)
         self.dict_user[self.username]["password"] = _password
         self.dict_user[self.username]["islocked"] = self.islocked
         self.dict_user[self.username]["name"] = self.name
         self.dict_user[self.username]["mobile"] = self.mobile
         self.dict_user[self.username]["bindcard"] = self.bindcard
         self.dict_user[self.username]["isdel"] = self.isdel
         self.dict_user[self.username]["role"] = self.role
         '''
         # 写入数据库文件
         my_jsonhelper.write_db_simplejson(self.dict_user, self.__database)
         return True
     except Exception as e:
         my_Common.write_error_log(e)
         return False