def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) return redirect(url_for('home')) else: flash("Login unsuccessfully. Please check username and password", 'danger') return render_template('login.html', title='Login', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): flash('You have been logged in!', 'success') login_user(user, remember=form.remember.data) return redirect(url_for('home')) else: flash('Login failed, Check credentials!', 'danger') return render_template('login.html', title='SignIn', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email = form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember = form.remember.data) next_page = request.args.get('next') return redirect(next_page) if next_page else redirect(url_for('main.home')) else: flash('Log In Unsuccessful. Please check the provided email and password', 'danger') return render_template('login.html', title = 'Login', form = form)
def login(): form = LoginForm() if current_user.is_authenticated: #if user is already logged in when they click on the login or register it redirects them to the home page return redirect(url_for("main.home")) if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user != None and bcrypt.check_password_hash(user.password, form.password.data): #checks to see if there email is valid and login them in login_user(user, remember=form.remember.data) nextpage = request.args.get('next') return redirect(nextpage) if nextpage != None else redirect( url_for("main.home")) else: flash("Login Unsuccessful, Please Try Again", "danger") return render_template("login.html", title="Login", form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) return redirect(url_for('home')) else: flash('Login Unsuccessful, Please check UserName and Password', 'danger') return render_template('login.html', title='Login', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('main.home')) form = LoginForm() if form.validate_on_submit(): # Remove because uses of login manager in models #if form.email.data == '*****@*****.**' and form.password.data == '123456': # flash('Logged in Successfully !','success') # return redirect(url_for('login')) #else: user = User.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) next_page = request.args.get('next') return redirect(next_page) if next_page else redirect( url_for('main.home')) else: flash('Login unsuccessful. Please check email and password.', 'danger') return render_template('login.html', title='Login', form=form)