def testPwdCheck(): u = User(0, "sksy", "1143") ud = UserDao() if ud.dbCheck(u): print("校验密码成功") else: print("校验密码失败")
def modifyInfo(): username = request.form['username'] originPwd = request.form['origin-pwd'] newPwd = request.form['new-pwd'] if username is None or originPwd is None or newPwd is None: return "ERROR: 不能为空" user = User(0, session['username'], originPwd) userDao = UserDao() if userDao.dbCheck(user): user.username = username user.password = newPwd print(str(user.ID) + user.username + user.password) if userDao.updSelf(user): return redirect(url_for("login")) else: return "内部错误" else: return "密码错误!"
def register(): username = request.form['username'] password = request.form['password'] if not (username is None and password is None): user = User(0, username, password) userDao = UserDao() if userDao.ins(user): session['username'] = username app.permanent_session_lifetime = timedelta(hours=12) return redirect(url_for('admin')) return render_template("admin-user-manage.html", repateName=True)
def selAll(self): selSql = "select * from t_user;" self.__cursor.execute(selSql) result = self.__cursor.fetchall() if result is None: return None ll = [] for it in result: user = User(it[0], it[1], None) ll.append(user) return ll
def login(): if request.method == "GET": return render_template('login.html') else: username = request.form['username'] password = request.form['password'] if not (username is None and password is None): user = User(0, username, password) userDao = UserDao() if userDao.dbCheck(user): session['username'] = username app.permanent_session_lifetime = timedelta(hours=12) return redirect(url_for('admin')) return render_template("login.html", loginError=True)
def testGetId(): u = User(0, "sksy", "1143") ud = UserDao() ud.selId(u) print("新的ID:" + str(u.ID))
def testAdd(): u = User(0, "Blue", "12345") ud = UserDao() ud.ins(u) print("新的ID:" + str(u.ID))
def testDel(): u = User(2, "sksy", "1143") ud = UserDao() ud.delete(u)
def testModifyInfo(): u = User(1, "sksy", "1143") ud = UserDao() ud.upd(u)