Skip to content

Commit c914a1b

Browse files
committed
working with config file
1 parent 2b949f0 commit c914a1b

12 files changed

Lines changed: 150 additions & 15 deletions

File tree

app/admin/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
data-busy="href">Login <span class="sr-only">(current)</span></a>
3838
</li>
3939
{% endif %}
40+
<li class="nav-item active">
41+
<a class="nav-link" href="{{ url_for('ds.choose_api') }}">Choose API <span class="sr-only">(current)</span></a>
42+
</li>
4043
</ul>
4144

4245
{% if session['ds_user_name'] %}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- extend base layout -->
2+
{% extends "base.html" %}
3+
4+
{% block content %}
5+
<div style="margin:1% 5%;">
6+
<h1 class="display-4">Please Choose an API</h1>
7+
8+
<form method="post" data-busy="form" action={{ url_for("ds.api_selected") }}>
9+
<div class="form-group col-md-5">
10+
<label for="chosen_api">Please choose your API</label>
11+
<select class="form-control" id="chosen_api" name="chosen_api">
12+
<option value="ESignature">eSignature</option>
13+
<option value="Rooms">Rooms</option>
14+
<option value="Click">Click</option>
15+
<option value="Monitor">Monitor</option>
16+
<option value="Admin">Admin</option>
17+
</select>
18+
<p class="lead" style="padding-top: .5rem;">
19+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
20+
<button type="submit" class="btn btn-docu">Choose your desired API</button>
21+
</p>
22+
</div>
23+
</form>
24+
<hr class="my-4">
25+
<p>You need to authenticate with DocuSign to continue your request.</p>
26+
</div>
27+
{% endblock %}

app/click/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
data-busy="href">Login <span class="sr-only">(current)</span></a>
3838
</li>
3939
{% endif %}
40+
<li class="nav-item active">
41+
<a class="nav-link" href="{{ url_for('ds.choose_api') }}">Choose API <span class="sr-only">(current)</span></a>
42+
</li>
4043
</ul>
4144

4245
{% if session['ds_user_name'] %}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- extend base layout -->
2+
{% extends "base.html" %}
3+
4+
{% block content %}
5+
<div style="margin:1% 5%;">
6+
<h1 class="display-4">Please Choose an API</h1>
7+
8+
<form method="post" data-busy="form" action={{ url_for("ds.api_selected") }}>
9+
<div class="form-group col-md-5">
10+
<label for="chosen_api">Please choose your API</label>
11+
<select class="form-control" id="chosen_api" name="chosen_api">
12+
<option value="ESignature">eSignature</option>
13+
<option value="Rooms">Rooms</option>
14+
<option value="Click">Click</option>
15+
<option value="Monitor">Monitor</option>
16+
<option value="Admin">Admin</option>
17+
</select>
18+
<p class="lead" style="padding-top: .5rem;">
19+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
20+
<button type="submit" class="btn btn-docu">Choose your desired API</button>
21+
</p>
22+
</div>
23+
</form>
24+
<hr class="my-4">
25+
<p>You need to authenticate with DocuSign to continue your request.</p>
26+
</div>
27+
{% endblock %}

app/docusign/ds_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ def _init(cls, auth_type):
4545
def _auth_code_grant(cls):
4646
"""Authorize with the Authorization Code Grant - OAuth 2.0 flow"""
4747
oauth = OAuth(app)
48-
if session["chosen_api"] == "rooms":
48+
if EXAMPLES_API_TYPE["Rooms"]:
4949
use_scopes = ROOMS_SCOPES
50-
elif session["chosen_api"] == "click":
50+
elif EXAMPLES_API_TYPE["Click"]:
5151
use_scopes = CLICK_SCOPES
52-
elif session["chosen_api"] == "admin":
52+
elif EXAMPLES_API_TYPE["Admin"]:
5353
use_scopes = ADMIN_SCOPES
5454
else:
5555
use_scopes = SCOPES
@@ -77,11 +77,11 @@ def _jwt_auth(cls):
7777
api_client = ApiClient()
7878
api_client.set_base_path(DS_JWT["authorization_server"])
7979

80-
if session["chosen_api"] == "rooms":
80+
if EXAMPLES_API_TYPE["Rooms"]:
8181
use_scopes = ROOMS_SCOPES
82-
elif session["chosen_api"] == "click":
82+
elif EXAMPLES_API_TYPE["Click"]:
8383
use_scopes = CLICK_SCOPES
84-
elif session["chosen_api"] == "admin":
84+
elif EXAMPLES_API_TYPE["Admin"]:
8585
use_scopes=ADMIN_SCOPES
8686
else:
8787
use_scopes = SCOPES

app/docusign/views.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,22 @@ def choose_api():
3434

3535
@ds.route("/api_selected", methods=["GET", "POST"])
3636
def api_selected():
37-
session["chosen_api"] = request.form.get("chosen_api")
37+
chosen_api = request.form.get("chosen_api")
38+
39+
if chosen_api == "ESignature":
40+
EXAMPLES_API_TYPE["ESignature"] = True
41+
elif chosen_api == "Rooms":
42+
EXAMPLES_API_TYPE["Rooms"] = True
43+
elif chosen_api == "Admin":
44+
EXAMPLES_API_TYPE["Admin"] = True
45+
elif chosen_api == "Monitor":
46+
EXAMPLES_API_TYPE["Monitor"] = True
47+
elif chosen_api == "Click":
48+
EXAMPLES_API_TYPE["Click"] = True
49+
50+
session["chosen_api"] = False
51+
session["chosen_api"] = chosen_api
52+
3853
ds_logout_internal()
3954
flash("You have logged out from DocuSign.")
4055
app.config["isLoggedIn"] = False
@@ -91,11 +106,11 @@ def ds_callback():
91106

92107
@ds.route("/must_authenticate")
93108
def ds_must_authenticate():
94-
if DS_CONFIG["quickstart"] == "true" and session["chosen_api"] == "e_signature":
109+
if DS_CONFIG["quickstart"] == "true" and EXAMPLES_API_TYPE["ESignature"]:
95110
session["auth_type"] = "code_grant"
96111
return redirect(url_for("ds.ds_login"))
97112

98-
elif session["chosen_api"] == "monitor":
113+
elif EXAMPLES_API_TYPE["Monitor"]:
99114
session["auth_type"] = "jwt"
100115
return redirect(url_for("ds.ds_login"))
101116

app/monitor/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
data-busy="href">Login <span class="sr-only">(current)</span></a>
3838
</li>
3939
{% endif %}
40+
<li class="nav-item active">
41+
<a class="nav-link" href="{{ url_for('ds.choose_api') }}">Choose API <span class="sr-only">(current)</span></a>
42+
</li>
4043
</ul>
4144

4245
{% if session['ds_user_name'] %}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- extend base layout -->
2+
{% extends "base.html" %}
3+
4+
{% block content %}
5+
<div style="margin:1% 5%;">
6+
<h1 class="display-4">Please Choose an API</h1>
7+
8+
<form method="post" data-busy="form" action={{ url_for("ds.api_selected") }}>
9+
<div class="form-group col-md-5">
10+
<label for="chosen_api">Please choose your API</label>
11+
<select class="form-control" id="chosen_api" name="chosen_api">
12+
<option value="ESignature">eSignature</option>
13+
<option value="Rooms">Rooms</option>
14+
<option value="Click">Click</option>
15+
<option value="Monitor">Monitor</option>
16+
<option value="Admin">Admin</option>
17+
</select>
18+
<p class="lead" style="padding-top: .5rem;">
19+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
20+
<button type="submit" class="btn btn-docu">Choose your desired API</button>
21+
</p>
22+
</div>
23+
</form>
24+
<hr class="my-4">
25+
<p>You need to authenticate with DocuSign to continue your request.</p>
26+
</div>
27+
{% endblock %}

app/rooms/templates/base.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
data-busy="href">Login <span class="sr-only">(current)</span></a>
3838
</li>
3939
{% endif %}
40+
<li class="nav-item active">
41+
<a class="nav-link" href="{{ url_for('ds.choose_api') }}">Choose API <span class="sr-only">(current)</span></a>
42+
</li>
4043
</ul>
4144

4245
{% if session['ds_user_name'] %}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!-- extend base layout -->
2+
{% extends "base.html" %}
3+
4+
{% block content %}
5+
<div style="margin:1% 5%;">
6+
<h1 class="display-4">Please Choose an API</h1>
7+
8+
<form method="post" data-busy="form" action={{ url_for("ds.api_selected") }}>
9+
<div class="form-group col-md-5">
10+
<label for="chosen_api">Please choose your API</label>
11+
<select class="form-control" id="chosen_api" name="chosen_api">
12+
<option value="ESignature">eSignature</option>
13+
<option value="Rooms">Rooms</option>
14+
<option value="Click">Click</option>
15+
<option value="Monitor">Monitor</option>
16+
<option value="Admin">Admin</option>
17+
</select>
18+
<p class="lead" style="padding-top: .5rem;">
19+
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
20+
<button type="submit" class="btn btn-docu">Choose your desired API</button>
21+
</p>
22+
</div>
23+
</form>
24+
<hr class="my-4">
25+
<p>You need to authenticate with DocuSign to continue your request.</p>
26+
</div>
27+
{% endblock %}

0 commit comments

Comments
 (0)