示例#1
0
def studentnewpw():
    message = '<div class="redalert"><center>'
    if request.method == "GET":
        return redirect(url_for("login"))
    else:
        u = request.form['user'].strip()
        op = request.form['oldpass'].strip()
        np1 = request.form['newpass1'].strip()
        np2 = request.form['newpass2'].strip()

        students = studentdb.studentdb()

        if np1 != np2:
            flash('New Passwords do not match, Please Try Again')
            return redirect(url_for("studentpwreset", usr=u))

        elif len(np1) < 6:
            flash(
                'Passwords must have at least 6 characters, Please Try Again')
            return redirect(url_for("studentpwreset", usr=u))

        elif students.authenticate(u, op):
            students.setPassword(u, np1)
            return redirect(url_for("studentlogout"))

        else:
            flash('Incorrect Password, Please Try Again')
            return redirect(url_for("studentpwreset", usr=u))
示例#2
0
def studentlogin():
    if request.method == "GET":
        return render_template("studentlogin.html")
    else:
        if 'user' in request.form:
            u = request.form['user'].strip()
            p = request.form['pass'].strip()
        else:
            u = 'anon'
        
        students = studentdb.studentdb()        
        if u not in students.getIDList():
            print u
            print 'no esta aqui'
            return redirect(url_for('studentlogin'))

        elif not students.isPasswordSet( u ):
            return render_template("studentpwset.html", user = u)
            
        elif students.authenticate( u, p ):
            session['user'] = u
            print session
            return redirect( url_for('studentview'))
        
        else:
            return redirect(url_for('studentlogin'))
示例#3
0
def studentpwset():
    if request.method == 'GET':
        return render_template("studentpwset.html")
    else:
        u = request.form['user'].strip()
        p = request.form['pass'].strip()
        p2 = request.form['pass2'].strip()

        if p == '' or p2 == '':
            return render_template(
                "studentpwset.html",
                user=u,
                message='Please enter a password into both boxes below')
        elif p != p2:
            return render_template(
                "studentpwset.html",
                user=u,
                message='Both passwords did not match, please try again.')
        else:
            students = studentdb.studentdb()
            students.setPassword(u, p)
            return render_template(
                "studentlogin.html",
                user=u,
                message='Your password has been set, please login below.')
示例#4
0
def studentlogin():
    if request.method == "GET":
        return render_template("studentlogin.html")
    else:
        if 'user' in request.form:
            u = request.form['user'].strip()
            p = request.form['pass'].strip()
        else:
            u = 'anon'

        students = studentdb.studentdb()
        if u not in students.getIDList():
            print u
            print 'no esta aqui'
            return redirect(url_for('studentlogin'))

        elif not students.isPasswordSet(u):
            return render_template("studentpwset.html", user=u)

        elif students.authenticate(u, p):
            session['user'] = u
            print session
            return redirect(url_for('studentview'))

        else:
            return redirect(url_for('studentlogin'))
示例#5
0
def studentnewpw():
    message = '<div class="redalert"><center>'
    if request.method == "GET":
        return redirect(url_for("login"))
    else:
        u = request.form['user'].strip()
        op = request.form['oldpass'].strip()
        np1 = request.form['newpass1'].strip()
        np2 = request.form['newpass2'].strip()

        students = studentdb.studentdb()

        if np1 != np2:
            flash('New Passwords do not match, Please Try Again')
            return redirect( url_for("studentpwreset", usr = u) )

        elif len(np1) < 6:
            flash('Passwords must have at least 6 characters, Please Try Again')
            return redirect( url_for("studentpwreset", usr = u) )
            
        elif students.authenticate( u, op ):
            students.setPassword( u, np1 )
            return redirect( url_for("studentlogout") )
 
        else:
            flash('Incorrect Password, Please Try Again')
            return redirect( url_for("studentpwreset", usr = u) )
示例#6
0
def studentpwset():
    if request.method == 'GET':
        return render_template("studentpwset.html")
    else:
        u = request.form['user'].strip()
        p = request.form['pass'].strip()
        p2 = request.form['pass2'].strip()

        if p == '' or p2 == '':
            return render_template("studentpwset.html", user = u, message = 'Please enter a password into both boxes below')
        elif p != p2:
            return render_template("studentpwset.html", user = u, message = 'Both passwords did not match, please try again.')
        else:
            students = studentdb.studentdb()
            students.setPassword( u, p )
            return render_template("studentlogin.html", user = u, message = 'Your password has been set, please login below.')
示例#7
0
def studentgradeload():
    sdb = studentdb.studentdb()
    grades = sdb.getGrades( session['user'], CURRENT_TERM )
    return json.dumps(grades)
示例#8
0
def studentload():
    sdb = studentdb.studentdb()
    cdb = db.db()
    student = sdb.getStudent( session['user'] )
    sdb.getGrades( session['user'], CURRENT_TERM )
    return json.dumps(student)
示例#9
0
def studentgradeload():
    sdb = studentdb.studentdb()
    grades = sdb.getGrades(session['user'], CURRENT_TERM)
    return json.dumps(grades)
示例#10
0
def studentload():
    sdb = studentdb.studentdb()
    cdb = db.db()
    student = sdb.getStudent(session['user'])
    #sdb.getGrades( session['user'], CURRENT_TERM )
    return json.dumps(student)