def afterreset(): form2 = ProfileForm() form = ResetpassForm() return render_template('profile.html', form2=form2, form=form, mng=mng, open=False)
def profile(): form2 = ProfileForm() form = ResetpassForm() return render_template('profile.html', form2=form2, form=form, mng=mng, open=True)
def firstfill(): form2 = ProfileForm() form = ResetpassForm() if form2.validate_on_submit(): if request.method == 'POST': result = request.form values = list(result.values()) addresstoverify = values[3] s1 = values[1] s2 = values[2] match2 = re.match("^[A-z][A-z|\.|\s]+$", s1) match3 = re.match("^[A-z][A-z|\.|\s]+$", s2) match1 = re.match('^[_a-z0-9-]+(\.[_a-z0-9-]+)*@enquero.com$', addresstoverify) if match1 == None: flash('Incorrect email address', 'danger') return redirect(url_for('firstfill')) elif match2 == None: flash('Incorrect First Name', 'danger') return redirect(url_for('firstfill')) elif match3 == None: flash('Incorrect Last Name', 'danger') return redirect(url_for('firstfill')) else: global a, mng, results1 cursor = connection1.cursor() select = ("SELECT * FROM profile WHERE empid='" + a + "'") cursor.execute(select) results = cursor.fetchone() if results == None: cursor = connection1.cursor() insert = ( "INSERT INTO profile (fname,lname,email,experience,practice,ejoindate,currentpro,location,gender,ques,ans,empid) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)" ) values = [ values[1], values[2], values[3], values[8], values[9], values[5], values[6], values[7], values[4], values[10], values[11], a ] cursor.execute(insert, values) connection1.commit() cursor.execute("SELECT * FROM profile WHERE empid='" + a + "'") results1 = cursor.fetchone() if mng != None: return redirect(url_for('skills')) else: return redirect(url_for('skills1')) return render_template('profile.html', form2=form2, form=form, mng=mng, open=False)
def firstreset(): form = ResetpassForm() form2 = ProfileForm() if form.validate_on_submit(): if request.method == 'POST': global a results = request.form values = list(results.values()) cursor = connection1.cursor() select = "SELECT password FROM signin where empid='" + a + "'" cursor.execute(select) results2 = cursor.fetchone() if bcrypt.check_password_hash(results2[0], values[1]): if values[2] == values[3]: if bcrypt.check_password_hash(results2[0], values[2]): flash('Old and New passwords must be different', 'danger') else: cursor = connection1.cursor() update = ( "UPDATE signin SET password =? where empid ='" + a + "'") hashed_password = bcrypt.generate_password_hash( values[2]).decode('utf-8') values = [hashed_password] cursor.execute(update, values) connection1.commit() return redirect(url_for('afterreset')) else: flash('Please enter same password in both fields', 'danger') else: flash('Incorrect Password', 'danger') return render_template('profile.html', form=form, form2=form2, mng=mng, open=True)