def login(): form = LoginForm() print('Here') if form.validate_on_submit(): print('Came Here') user = User.query.filter_by(email=form.email.data).first() if user.check_password(form.password.data) and user is not None: print('Came Here also') login_user(user) flash('Log in Successful!!') next = request.args.get('next') if next == None or not next[0] == '/': next = url_for('core.index') return redirect(url_for('core.index')) else: flash('login failed') print('i ma here') return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user.check_password(form.password.data) and user is not None: login_user(user) flash('You successfully logged in') # if user has been redirected from another page next = request.args.get('next') if next == None or not next[0] == '/': next = url_for('core.index') return redirect(next) return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user.check_password(form.password.data) and user is not None: login_user(user) flash('Login Successful') # next here is the next page the user wants to navigate upon login next = request.args.get('next') # if there is no next page we produce the index page if next == None or next[0] == '/': next = url_for('core.index') # else we redirect the user to the either the next page they requested for or the index page return redirect(next) return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user.check_password(form.password.data) and user is not None: login_user(user) flash('Log in Successful!') next = request.args.get( 'next' ) #From the current session, get what/the page, the user was trying to access if next == None or not next[0] == '/': next = url_for('core.index') return redirect(next) return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user is not None and user.check_password(form.password.data): login_user(user) flash('Login success!', 'success') next = request.args.get('next') if next is None or not next[0] == '/': next = url_for('core.index') return redirect(next) if request.method == 'POST': flash('Incorrect email or password.', 'danger') return render_template('login.html', form=form)