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('index')) else: flash("Login Unsuccessful. Please check email and password", 'danger') return render_template('login.html', title='Login', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): user = User.query.filter_by(username=form.username.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=True) flash(f'Welcome {user.username}', 'success') return redirect(url_for('home')) else: flash(f'Login Failed, Please check username and password', 'danger') return render_template('auth/login.html', 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("Login Unsuccesful!!!", '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 your email and password. ', 'danger') return render_template('login.html', title='Login', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): # if form.email.data == '*****@*****.**' and form.password.data == 'tej': # flash(f'Logged in as {form.email.data} !!! ', category='success') # return redirect(url_for('home')) # 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.rememberMe.data) next_page = request.args.get('next') flash(f'Logged in as {user.username} !!! ', category='success') return redirect(next_page) if next_page else redirect(url_for('main.home')) else: flash(f'Login failed', category='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) flash(f'You are logged in', 'success') next_page = request.args.get('next') if next_page: return redirect(next_page) else: return redirect(url_for('home')) else: flash(f'Invalid credentials', 'danger') return render_template('login.html', title='Sign In', form=form)
def login(): if current_user.is_authenticated: return redirect(url_for("main.home")) form = LoginForm() posts = Post.query.all() if form.validate_on_submit(): user = User.query.filter_by(email=str(form.email.data).lower()).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user, remember=form.remember.data) usersLoggedIn(user.username, user.id, user.administrator) 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, posts=posts)
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) next_page = request.args.get( 'next' ) #args is a dictionary we use get method so that if the next prameter dost not exits it gives none so dont use square brackets with the key return redirect(next_page) if next_page else redirect( url_for('home') ) # this is done so that if login page is directed from a restricted page then after login it redirects to that page instead of home page else: flash("Login Unsuccessful, Please check your email and password", "danger") return render_template('login.html', title='Login', form=form)