Skip to content

Commit 1d9d331

Browse files
author
robert-knight
committed
Set quickstart to false when logged out
1 parent c440b12 commit 1d9d331

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

app/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from flask import Flask
44
from flask_wtf.csrf import CSRFProtect
55

6+
from .ds_config import DS_CONFIG
67
from .eSignature import examples
78
from .docusign.views import ds
89
from .views import core
@@ -14,6 +15,12 @@
1415
# See https://flask-wtf.readthedocs.io/en/stable/csrf.html
1516
csrf = CSRFProtect(app)
1617

18+
# Set whether this is a quickstart in config
19+
app.config["quickstart"] = DS_CONFIG["quickstart"]
20+
21+
# Set whether user has logged in
22+
app.config["isLoggedIn"] = False
23+
1724
# Register home page
1825
app.register_blueprint(core)
1926
# Register OAuth

app/docusign/views.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import datetime, timedelta
22

3-
from flask import redirect, request, url_for, flash, render_template, Blueprint, session
3+
from flask import redirect, request, url_for, flash, render_template, Blueprint, session, current_app as app
44

55
from .ds_client import DSClient
66
from .utils import ds_logout_internal
@@ -14,13 +14,17 @@
1414
def ds_login():
1515
if not session.get("auth_type"):
1616
session["auth_type"] = request.form.get("auth_type")
17+
app.config["isLoggedIn"] = True
18+
app.config["quickstart"] = DS_CONFIG["quickstart"]
1719
return DSClient.login(session["auth_type"])
1820

1921

2022
@ds.route("/logout")
2123
def ds_logout():
2224
ds_logout_internal()
2325
flash("You have logged out from DocuSign.")
26+
app.config["isLoggedIn"] = False
27+
app.config["quickstart"] = False
2428
return redirect(url_for("core.index"))
2529

2630

@@ -52,12 +56,12 @@ def ds_callback():
5256
if target_account_id:
5357
account = next((a for a in accounts if a["account_id"] == target_account_id), None)
5458
if not account:
55-
# Panic! The user does not have the targeted account. They should not log in!
59+
# The user does not have the targeted account. They should not log in!
5660
raise Exception("No access to target account")
5761
else: # get the default account
5862
account = next((a for a in accounts if a["is_default"]), None)
5963
if not account:
60-
# Panic! Every user should always have a default account
64+
# Every user should always have a default account
6165
raise Exception("No default account")
6266

6367
# Save the account information

app/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Defines the home page route"""
22

3-
from flask import render_template, url_for, redirect, Blueprint
3+
from flask import render_template, url_for, redirect, Blueprint, current_app as app
44
from .ds_config import DS_CONFIG
55

66
core = Blueprint("core", __name__)
@@ -9,8 +9,8 @@
99
@core.route("/")
1010
def index():
1111
#if quickstart go to eg001 else go to homepage
12-
quickstart=DS_CONFIG["quickstart"]
13-
if quickstart == "true":
12+
quickstart=app.config["quickstart"]
13+
if quickstart == True:
1414
return render_template("eg001_embedded_signing.html", title="Embedded signing ceremony")
1515
else:
1616
return render_template("home.html", title="Home - Python Code Examples")

0 commit comments

Comments
 (0)