def login_view(request): if request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user: login(request, user) return redirect('home', permanent=True) return render(request, 'login_failed.html', status=403) login_form = LoginForm() return render(request, 'login.html', context={'form': login_form})
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by(username=form.username.data).first() if attempted_user and attempted_user.check_password_correction(attempted_password=form.password.data): login_user(attempted_user) flash(f'Success! You are logged in as: {attempted_user.username}', category='success') return redirect(url_for('market_page')) else: flash('Username and password are not a match! Please try again!', category='danger') return render_template('login.html', form=form)
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by(username=form.username.data).first() if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash(f"Success! you are logged in as {attempted_user.username}", category="success") return redirect(url_for('market_page')) else: flash(f"Username and Password does not match! Please try again.", category="danger") return render_template('login.html',form = form)
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by(username=form.username.data).first() if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data ): login_user(attempted_user) flash(f"Success! You are logged in as: {attempted_user.username}", category="success") return redirect(url_for("market_page")) else: flash("User and password are not match! Try again!", category="danger") return render_template("login.html", form=form)
def login_page(): form = LoginForm() #Validate the forms for requirements if form.validate_on_submit(): attempted_user = User.query.filter_by( username=form.username.data).first() if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash(f'Login successful as {attempted_user.username}', category='success') return redirect(url_for('market_page')) else: flash('Login failed! Incorrect User Name or Password', category='danger') return render_template('login.html', form=form)
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by( username=form.username.data).first() if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash("Login successful for {}".format(attempted_user.username), category="success") return redirect(url_for("market_page")) else: flash("Login unsuccessful!!!", category="danger") return render_template("login.html", form=form)
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by( username=form.username.data).first() if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash( f'Login Exitoso, tu nombre de usuario es: {attempted_user.username}', category='success') return redirect(url_for('market_page')) else: flash('Nombre de usuario y password no coinciden, intenta denuevo', category='danger') return render_template('login.html', 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( username=form.username.data.lower()).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(f'Login Unsuccesful! Please try again.', '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: if bcrypt.check_password_hash(user.password_hash, form.password.data): login_user(user) flash( f'Welcome {user.username.capitalize()}! You are now logged in!', category='success') return redirect(url_for('market')) flash('Wrong password!', category='danger') return redirect(url_for('login')) flash('User does not exist', category='danger') return render_template('login.html', form=form)
def login_page(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by(username=form.username.data).first() if attempted_user and attempted_user.check_password_correction(attempted_password = form.password.data): if attempted_user.username == 'admin': login_user(attempted_user) flash("Welcome Admin",category="success") return redirect(url_for('admin_page')) else: login_user(attempted_user) flash(f"Login Successfull! Welcome: {attempted_user.username.capitalize()}",category='success') return redirect(url_for('market_page')) else: flash('Username and password not matched',category = 'danger') return render_template('login.html',form=form)
def login(): form = LoginForm() if form.validate_on_submit(): attempted_user = User.query.filter_by(email=form.email.data) if attempted_user: attempted_user = attempted_user.first() if attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash(f'Your are logged in as {attempted_user.username}', category="success") return redirect(url_for("market")) else: flash("Wrong Password", category='danger') else: flash("The user does not exist please create an account", category='danger') return render_template('login.html', form=form)
def login_page(): form = LoginForm() # this function will execute 2 actions: 1) validate_ any fields that I have in forms, and # 2) then execute the on_submit function if form.validate_on_submit(): # step 1: check if the user exists attempted_user = User.query.filter_by( username=form.username.data).first() # step 2: check if the password is correct if attempted_user and attempted_user.check_password_correction( attempted_password=form.password.data): login_user(attempted_user) flash(f'Success! You are logged in as: {attempted_user.username}', category='success') return redirect(url_for('market_page')) else: flash('Username and password are not match! Please try again', category='danger') return render_template('login.html', form=form)
def login_page(): form = LoginForm() context = {"form": form} if form.validate_on_submit(): attempt_user = User.query.filter_by( username=form.username.data).first() if attempt_user and attempt_user.check_password(form.password.data): login_user(attempt_user) flash(f'Success! You are logged in as {attempt_user.username}', 'success') return redirect(url_for('market_page')) elif attempt_user: flash('Invalid credentials', 'danger') else: flash('User does not exist!', 'danger') if form.errors != {}: for err_msg in form.errors.values(): flash('Invalid credentials', category='danger') return render_template("login.html", **context)
def login_page(): form = LoginForm() return render_template('login.html', form=form)