def login_view(request): #function for performing login response_data = {} if request.method == "POST": form = Loginform(request.POST) #for submitting the form if form.is_valid(): username = form.cleaned_data.get('username') password = form.cleaned_data.get('password') user = UserModel.objects.filter(username=username).first() if user: if check_password(password, user.password): token = Sessiontoken(user=user) token.create_token()#create a token token.save()#save token response = redirect('feed/') response.set_cookie(key='session_token', value=token.session_token) return response#redirects to the feeds page else: response_data['message'] = 'Incorrect Password! Please try again!' elif request.method == 'GET': form = Loginform() response_data['form'] = form return render(request, 'login.html', response_data)
def login(): form = Loginform() if form.validate_on_submit(): if form.email.data == '*****@*****.**' and form.password.data == 'dinesh1342': flash(f'Welcome {form.email.data}!!', 'success') return redirect(url_for('home')) else: flash('Check your username and password', 'danger') return render_template('login.html', title="Registration", form=form)
def login(): form = Loginform() if form.validate_on_submit(): if form.Email.data == '*****@*****.**' and form.Password.data == 'Password': flash('You have been logged in !', 'success') return redirect(url_for('home')) else: flash( 'Login unsuccessful.Please check username and password correctly!', 'danger') return render_template("login.html", title='login', form=form)
def show_signup_form(): form = Loginform() if form.validate_on_submit(): name = form.name.data email = form.email.data password = form.password.data next = request.args.get('next', None) if next: return redirect(next) return redirect(url_for('index')) return render_template("signup_form.html", form=form)
def login(): form = Loginform() if form.validate_on_submit(): if form.email.data == '*****@*****.**' and form.password.data == 'password': flash('You Have been logged in!', 'success') return redirect(url_for('home')) else: flash( 'Login Unsuccessful. Please check your username and password', 'danger') return render_template('login.html', title='login', form=form)
def login(): form = Loginform() if request.method == 'POST': if form.validate_on_submit(): user = User.query.filter_by(email=form.email.data).first() if user is not None: if user.verify_password(form.password.data): login_user(user) return redirect(url_for('users.dashboard')) flash('Wrong password') flash('Invalid email') return render_template('login.html', form=form, title='login')
def checkdb(): form1 = Loginform() if form1.validate_on_submit() and request.method == 'POST': user = request.form['username'] session['username'] = request.form['username'] passwd = request.form['password'] a = User.query.filter_by(username=user, password=passwd).first() if a is not None: return redirect(url_for('home')) else: return redirect(url_for('login')) else: return redirect(url_for('login'))
def login(): if not current_user.is_authenticated: form = Loginform() if form.validate_on_submit(): user = User.query.filter_by(user_email=form.email.data).first() print(user) if user: #session['username'] = form.username.data if check_password_hash(user.user_password,form.password.data): login_user(user,remember=form.remember.data) return redirect(url_for('index')) return render_template('login.html',form=form,message="Incorrect username or password") return render_template('login.html',form=form) return redirect((url_for('index')))
def login(): global form form = Loginform() nome = str(form.inputEmail.data).upper() result = models.conn.execute(models.s, nome=form.inputEmail.data).fetchone() if form.validate_on_submit() and nome == result[2] and form.inputPassword.data.strip()== result[3]: global session session["username"] = result[0] print(session["username"]) fotos() print(result[1]) return redirect(url_for('index')) else: print(form.errors) return render_template('login.html', form=form)
def login(): if 'email' in session: return redirect(url_for('app')) form = Loginform() if request.method == "POST": if form.validate() == False: return render_template("../static/partials/login.html", form=form) else: email = form.email.data password = form.password.data user = User.query.filter_by(email=email).first() if user is not None and user.check_password(password): session['email'] = form.email.data return redirect(url_for('app')) else: return redirect(url_for('login')) elif request.method == "GET": return render_template("../static/partials/login.html", form=form)
def login(request): form = Loginform() if request.method == 'POST': form = Loginform(request.POST) if form.is_valid(): Usr = request.POST.get('Username') pwd = request.POST.get('Password') p = Login(Username=Usr, Password=pwd) p.save() return HttpResponseRedirect(reverse('Done')) else: form = Loginform() return render(request, 'login/login.html', {'form': form})
def Authen(request): form = Loginform() if request.method == 'POST': form = Loginform(request.POST) if form.is_valid(): Usr = request.POST.get('Username') pwd = request.POST.get('Password') log = Login.objects.all() for i in log: if (i.Username == Usr and i.Password == pwd): return render( request, 'login/done.html', {'Logi': i} ) #HttpResponseRedirect(reverse('Done'))# render('login/done.html',{'Logi': i})HttpResponseRedirect(reverse('Done'),{'Logi' :i}) #redirect('/customer/done', {foo :'log'})#HttpResponseRedirect(reverse('Done'),{'Logi' :log}) else: form = Loginform() return render(request, 'login/login.html', {'form': form})
def login(): form = Loginform(request.form) if request.method == 'POST': email = request.form['email'] password_candidate = request.form['password'] cs = db.cursor() try: selectquery = 'SELECT username,password FROM users WHERE email = %s' result = cs.execute(selectquery, email) if (result > 0): get_row = cs.fetchone() db_password = get_row['password'] #compare passwords if sha256.verify(password_candidate, db_password): username = get_row['username'] #show info in console app.logger.info('Passwords matched') #Start session session['logged_in'] = True session['username'] = username session['email'] = email flash('You are now logged in!', 'success') return redirect(url_for('dashboard')) else: error = 'Username/Password is incorrect!' return render_template('login.html', form=form, error=error) else: error = 'Username/Password is incorrect!' return render_template('login.html', form=form, error=error) except Exception as e: flash('Something went wrong: ' + str(e), 'danger') db.rollback() finally: cs.close() return render_template('login.html', form=form, title='Login')
def login(): form = Loginform() return render_template('login.html', title='login', form=form)