Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. @app.route('/login', methods=['GET', 'POST'])
  2. def login():
  3. return render_template("login.html")
  4.  
  5. @app.route('/logincheck', methods=['GET', 'POST'])
  6. def logincheck():
  7. error = None
  8. checkP = g.db.execute('select pword from users where uname = ?', (request.form['username'], ))
  9. arrayCheck = checkP.fetchall()
  10. if request.method == 'POST':
  11. if request.form['password'] != arrayCheck[[0][0]]:
  12. error = 'Username or password is incorrect'
  13. return redirect(url_for('login'))
  14. if len(arrayCheck) == 0:
  15. error = 'Username or password is incorrect'
  16. return redirect(url_for('login'))
  17. else:
  18. session['logged_in'] = True
  19. flash('You are logged in')
  20. return redirect(url_for('userpage'))
  21. return render_template('login.html')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement