def example3login(): username = request.POST['username'] password = request.POST['password'] error = False user = authenticate(username, password) if user: login(user) redirect('/example3/') else: error = True return dict(username=username, error=error)
def authqbo(): status = login(request.cookies) if status is not None: return redirect(status) # calls fn to grab qbo auth url and then redirects there if fetch('qb_secret') is not None: return redirect(qbo.get_auth_url()) else: return redirect(url_for('set_keys'))
def task_list(): status = login(request.cookies) if status is not None: return redirect(status) jobs = scheduler._scheduler.get_jobs() string = '' for job in jobs: string = string + str(job) + ' ' + str(job.next_run_time) + '\n' return string
def set_keys(): status = login(request.cookies) if status is not None: return redirect(status) form = KeysForm() if form.validate_on_submit(): save('qb_id', form.qb_id.data) save('qb_secret', form.qb_secret.data) save('qb_sandbox', form.qb_sandbox.data) return redirect(url_for('authqbo')) return render_template( 'setkeys.html', title='Set Intuit Keys', form=form )
def auth(): '''This page has 2 modal forms. (For a simpler example, see the bootstrap 4 example.) Call `render_template_modal` instead of `render_template`. It takes the modal id (default 'modal-form') as an argument apart from the arguments passed to `render_template`. ''' form1 = RegistrationForm() form2 = LoginForm() modal = session.pop('modal', None) ajax = '_ajax' in request.form form = '' if 'password2' in request.form: form = 'form1' modal = 'register-modal' elif 'password' in request.form: form = 'form2' modal = 'login-modal' if form == 'form1' and form1.validate_on_submit(): retval = register(form1, ajax) if retval is None: return '' if retval: flash('You have registered successfully! Please login.', 'success') return redirect(url_for('auth')) else: flash('Could not register.', 'danger') session['modal'] = 'register-modal' return redirect(url_for('auth')) if form == 'form2' and form2.validate_on_submit(): retval = login(form2.username.data, form2.password.data, ajax) if retval is None: return '' if retval: flash('You have logged in successfully!', 'success') return redirect(url_for('subscribe')) else: flash('Invalid credentials.', 'danger') session['modal'] = 'login-modal' return redirect(url_for('auth')) return render_template_modal('auth.html', form1=form1, form2=form2, modal=modal)
def authbtc(): # accepts BTCPay pairing code and calls pairing fn status = login(request.cookies) if status is not None: return redirect(status) form = BTCCodeForm() url = urljoin(str(os.getenv('BTCPAY_HOST')), 'api-tokens') if form.validate_on_submit(): client = BTCPayClient.create_client( host=app.config.get('BTCPAY_HOST'), code=form.code.data, ) save('btc_client', client) save('forward_url', form.forward_url.data) flash('Pairing to BTCPay Successful') return render_template('index.html') return render_template( 'authbtc.html', title='Enter Code', form=form, url=url )
def setmail(): # sets user email settings status = login(request.cookies) if status is not None: return redirect(status) form = MailForm() if form.validate_on_submit(): save('mail_on', form.mail_on.data) save('mail_user', str(form.mail_user.data)) save('mail_pswd', str(form.mail_pswd.data)) save('mail_host', str(form.mail_host.data)) save('mail_port', int(form.mail_port.data)) save('mail_from', str(form.mail_from.data)) save('merchant', str(form.merchant.data)) save('mail_custom', form.mail_custom.data) if form.recipient.data is not None and str(form.recipient.data) != "": try: send( dest=form.recipient.data, qb_inv='test', btcp_inv='test', amt=0.00, ) except Exception as e: app.logger.exception(e) flash('Connection to SMTP server failed.') return render_template('index.html') flash('Test email sent.') else: flash('Email settings updated.') return render_template('index.html') return render_template( 'setmail.html', title='Email Settings', form=form, )
def index(): status = login(request.cookies) if status is not None: return redirect(status) return render_template('index.html')