def admin_change_pwd(id, old_pwd, new_pwd1, new_pwd2): if new_pwd1 != new_pwd2: return False old_pwd = Encryption.md5(old_pwd) try: admin = Admins.query.get(id) if admin.password != old_pwd: return False admin.password = Encryption.md5(new_pwd1) db.session.add(admin) db.session.commit() return True except Exception as e: print(e) ExceptionLog.model_error(e.__str__()) try: db.session.rollback() except Exception as ex: print(ex) ExceptionLog.other_error(ex.__str__()) return False
def admin_pwd_check(user, pwd): admin = None try: user = int(user) pwd = Encryption.md5(pwd) admin = Admins.query.filter_by(ano=user, password=pwd).first() except Exception as e: # 保存日志 ExceptionLog.model_error(e.__str__()) print(e) return admin
def tea_pwd_check(user, pwd): tea = None try: user = int(user) pwd = Encryption.md5(pwd) tea = Teachers.query.filter_by(tno=user, password=pwd).first() except Exception as e: # 保存日志 ExceptionLog.model_error(e.__str__()) print(e) return tea
def stu_pwd_check(user, pwd): stu = None try: user = int(user) pwd = Encryption.md5(pwd) # 加密转换密码 # 通过账号和密码查询数据库,获取用户信息对象 stu = Students.query.filter_by(sno=user, password=pwd).first() except Exception as e: # 保存日志 ExceptionLog.model_error(e.__str__()) print(e) return stu # 返回用户信息对象,如果没有则为None
def add(cls, tno, tname, tsex, collegename, password, tel): tea = Teachers( tno=tno, tname=tname, tsex=tsex, collegename=collegename, password=Encryption.md5(password), tel=tel ) try: db.session.add(tea) db.session.commit() return True except Exception as e: print(e) db.session.rollback() return False
def add(ano, password): admin = Admins(ano=ano, password=Encryption.md5(password), pwd=password, issuper=0, examine=0) try: db.session.add(admin) db.session.commit() return True except Exception as e: print(e) ExceptionLog.model_error(e.__str__()) try: db.session.rollback() except Exception as ex: print(ex) ExceptionLog.other_error(ex.__str__()) return False
def set_pwd(self, pwd): self.password = Encryption.md5(pwd)