Exemplo n.º 1
0
def testPwdCheck():
    u = User(0, "sksy", "1143")
    ud = UserDao()
    if ud.dbCheck(u):
        print("校验密码成功")
    else:
        print("校验密码失败")
Exemplo n.º 2
0
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 "密码错误!"
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
 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
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
def testGetId():
    u = User(0, "sksy", "1143")
    ud = UserDao()
    ud.selId(u)
    print("新的ID:" + str(u.ID))
Exemplo n.º 7
0
def testAdd():
    u = User(0, "Blue", "12345")
    ud = UserDao()
    ud.ins(u)
    print("新的ID:" + str(u.ID))
Exemplo n.º 8
0
def testDel():
    u = User(2, "sksy", "1143")
    ud = UserDao()
    ud.delete(u)
Exemplo n.º 9
0
def testModifyInfo():
    u = User(1, "sksy", "1143")
    ud = UserDao()
    ud.upd(u)