def login(): if current_user.is_authenticated: flash('You are already logged in.', 'success') 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') flash('Logged in successful.', 'success') return redirect(next_page) if next_page else redirect( url_for('home')) if user and not bcrypt.check_password_hash(user.password, form.password.data): flash('Login Unsuccessful. Please check your password', 'danger') return redirect(url_for('login')) if not user: flash('Failed!, it seems you are not a member. ', 'danger') return redirect(url_for('register')) else: flash('Login Unsuccessful. Please check email 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(): 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 Un-successfull. Please check the Credentials','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(): 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 try again!", "danger") return render_template("login.html", title="Login", form=form)
def login(): if current_user.is_authenticated: return redirect(url_for('home')) login = LoginForm() if login.validate_on_submit(): person = user_collection.find_one({'email': login.email.data}) if person and bcrypt.check_password_hash(person['password'], login.password.data): user_obj = User(person['username'], person['email'], person['image']) login_user(user_obj, login.remember.data) next_page = request.args.get('next') if next_page: return redirect(next_page) flash('Welcome to BlogApp', 'success') return redirect(url_for('home')) else: flash('Login unsuccessful. Please check your email or password again.', 'danger') return render_template('login.html', title = 'Login', form = login)
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') return redirect(next_page) if next_page else redirect( url_for('home')) else: flash( 'Logowanie nieudane. Sprawdź czy email i hasło zostało wpisane prawidłowo.', 'danger') return render_template('login.html', title='Login', form=form)
def check_password(self, password): return bcrypt.check_password_hash(self.password, password)