Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route('/login', methods=['GET','POST'])
- def login():
- if request.method == 'POST':
- email = request.form['email']
- password = request.form['password'].encode('utf-8')
- cur = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
- cur.execute("SELECT * FROM users WHERE user_email=%s",(email))
- user = cur.fetchone()
- cur.close()
- if len(user) > 0:
- if bcrypt.hashpw(password, user['password'].encode('utf-8')) == user['password'].encode('utf-8'):
- session['name'] == user['name']
- session['email'] == user['email']
- return render_template("home.html")
- else:
- return "Username or Password Incorrect."
- else:
- return render_template('login.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement