def populate_db(): """ Adds fake data to the database. """ admin = User(username='******', password='******', first_name='chris', last_name='hall') db.session.add(admin) db.session.commit()
def login(): # If the user is already signed in, redirect him Dashboard. if current_user.is_authenticated: return redirect(url_for('dashboard')) if request.method == 'POST': form_username = request.form['username'] userObj = User() user = userObj.get_by_username_w_password(form_username) if user and check_password_hash(user.password, request.form['password']): login_user(user) return redirect(url_for('dashboard')) else: flash(u'Incorrent password.', 'incorrect_password') return render_template('login.html')