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
예제 #2
0
    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
예제 #3
0
    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
예제 #4
0
    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
예제 #5
0
 def stu_to_dict(stu):
     sex = ["女", "男"]
     d = {
         "id": stu.id,
         "sno": stu.sno,
         "sname": stu.sname,
         "ssex": sex[stu.ssex],
         "collegename": stu.college.collname,
         "classname": stu.classes.clname,
         "level": stu.level.lname,
         "nativeplace": stu.nativeplace,
         "birthday": stu.birthday,
         "tel": stu.tel,
         "campus": stu.campus.caname,
         "degree": stu.degree,
         "pid": Encryption.base64_decode(stu.pid)
     }
     return d
예제 #6
0
    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
예제 #7
0
    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)
 def set_pid(self, pid):
     self.pid = Encryption.base64_encode(pid)