def resetPassword(username): #reset a user's password if session['username']=='admin': if request.method=="POST": if len(request.form['newPassword'])>=10 and len(request.form['newPassword'])<=50: if request.form['newPassword']==request.form['newPasswordConfirm']: if idea_box.changePassword(username,request.form['newPassword']): flash(username+ ' password reset Success!') return redirect(url_for('admin')) else: flash('SQL Error') else: flash("Passwords don't match") else: flash("10-50 Characters admin") return render_template('adminPassword.html',username=username) else: return redirect(url_for('welcome'))
def editPassword(): #change password, verify old password, check new password if session.get('logged_in'): if request.method=="POST": #ready to change? if idea_box.signInVerify(session['username'],request.form['oldPassword'])==1: #a bunch of checks if request.form['newPassword']==request.form['newPasswordConfirm']: if idea_box.changePassword(session['username'],request.form['newPassword']): flash("Password change successful!") return redirect(url_for('welcome')) else: flash("Password length incorrect!") else: flash("Passwords do not match!") else: flash("Password incorrect") return render_template('editPassword.html') else: return redirect(url_for('welcome'))
def changePW(): #this function changes the password try: #create a new use with a randomly generated username print "Attempting Password change" session=idea_box.createAll() username="******".lower() password="******" if idea_box.changePassword(username,password,session): print "Password Changed" else: print "Password not changed" session.close() except: print "Password change error" raise else: print "Passowrd Change complete" outputUser(username.lower())