示例#1
0
 def refresh_key(self):
     session = DBSession()
     self.key = random_str(32)
     self.key_time = int(time.time())
     session.add(self)
     session.commit()
     session.close()
示例#2
0
 def refresh_key(self):
     session = DBSession()
     self.key = random_str(32)
     self.key_time = int(time.time())
     session.add(self)
     session.commit()
     session.close()
示例#3
0
 def set_password(self, new_password):
     salt = random_str()
     password_md5 = md5(new_password.encode('utf-8')).hexdigest()
     password_final = md5((password_md5 + salt).encode('utf-8')).hexdigest()
     session = DBSession()
     self.salt = salt
     self.password = password_final
     session.add(self)
     session.commit()
     session.close()
示例#4
0
 def set_password(self, new_password):
     salt = random_str()
     password_md5 = md5(new_password.encode('utf-8')).hexdigest()
     password_final = md5((password_md5 + salt).encode('utf-8')).hexdigest()
     session = DBSession()
     self.salt = salt
     self.password = password_final
     session.add(self)
     session.commit()
     session.close()
示例#5
0
 def new(cls, username, password):
     salt = random_str()
     password_md5 = md5(password.encode('utf-8')).hexdigest()
     password_final = md5((password_md5 + salt).encode('utf-8')).hexdigest()
     level = USER_LEVEL.ADMIN if cls.count() == 0 else USER_LEVEL.NORMAL  # 首个用户赋予admin权限
     the_time = int(time.time())
     session = DBSession()
     ret = User(username=username, password=password_final,openid=openid , salt=salt, level=level, key=random_str(32),
                       key_time = the_time, )
     session.add(ret)
     session.commit()
     session.close()
     return ret
示例#6
0
 def new(cls, username, password):
     salt = random_str()
     password_md5 = md5(password.encode('utf-8')).hexdigest()
     password_final = md5((password_md5 + salt).encode('utf-8')).hexdigest()
     level = USER_LEVEL.ADMIN if cls.count(
     ) == 0 else USER_LEVEL.NORMAL  # 首个用户赋予admin权限
     the_time = int(time.time())
     session = DBSession()
     ret = User(
         username=username,
         password=password_final,
         openid=openid,
         salt=salt,
         level=level,
         key=random_str(32),
         key_time=the_time,
     )
     session.add(ret)
     session.commit()
     session.close()
     return ret