Skip to content

Commit 11b5906

Browse files
Handle logins to different jurisdictions better
* don't act like logging in to one jurisdiction logs you into all of them * don't make the template context always have `is_logged_in` * Show the "Sign in" button in the profile if not already logged in
1 parent 012a1bd commit 11b5906

4 files changed

Lines changed: 30 additions & 4 deletions

File tree

efile_app/efile/templates/efile/components/profile_header.html

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
aria-hidden="true">
2727
<div class="modal-dialog modal-dialog-centered">
2828
<div class="modal-content">
29+
{% if is_logged_in|default:True %}
2930
<div class="modal-header">
3031
<h5 class="modal-title" id="profileModalLabel">{% translate "Profile Info" %}</h5>
3132
<button type="button"
@@ -35,16 +36,31 @@ <h5 class="modal-title" id="profileModalLabel">{% translate "Profile Info" %}</h
3536
</div>
3637
<div class="modal-body">
3738
<p>
38-
{% blocktranslate %}Welcome to {{ config.jurisdiction.name }}. Here you can manage your filings and account.{% endblocktranslate %}
39+
{% blocktranslate with name=config.jurisdiction.name %}Welcome to {{ name }}. Here you can manage your filings and account.{% endblocktranslate %}
3940
</p>
4041
<div class="mb-3">
4142
<span class="form-label">{% translate "Current email" %}</span>: {{ user.username }}
4243
</div>
4344
<div class="mb-3">
4445
<span class="form-label">{% translate "Current Jurisdiction" %}</span>: {{ jurisdiction }}
4546
</div>
46-
<button type="button" class="btn btn-danger w-100" onclick="logout()">Logout</button>
47+
<button type="button" class="btn btn-danger w-100" onclick="logout()">{% translate "Sign out" %}</button>
4748
</div>
49+
{% else %}
50+
<div class="modal-header">
51+
<h5 class="modal-title" id="profileModalLabel">{% translate "Sign in to get started" %}</h5>
52+
<button type="button"
53+
class="btn-close"
54+
data-bs-dismiss="modal"
55+
aria-label="Close"></button>
56+
</div>
57+
<div class="modal-body">
58+
<p>
59+
{% blocktranslate with name=config.jurisdiction.name %}Welcome to {{ name }}.{% endblocktranslate %}
60+
</p>
61+
<button type="button" class="btn btn-primary w-100" onclick="login()">{% translate "Sign in" %}</button>
62+
</div>
63+
{% endif %}
4864
</div>
4965
</div>
5066
</div>
@@ -92,4 +108,8 @@ <h5 class="modal-title" id="profileModalLabel">{% translate "Profile Info" %}</h
92108
window.location.href = '/jurisdiction/{{jurisdiction}}/logout/';
93109
});
94110
}
111+
112+
function login() {
113+
window.location.href = '/jurisdiction/{{jurisdiction}}/login/';
114+
}
95115
</script>

efile_app/efile/templates/efile/confirmation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h1 class="h2 mb-3" style="color: #2c5aa0;">{% translate "Filing Submitted Succe
3434
</a>
3535
<a href="{% url 'efile_logout' jurisdiction %}"
3636
class="btn btn-outline-secondary">
37-
<i class="fas fa-arrow-right me-2"></i>{% translate "Logout" %}
37+
<i class="fas fa-arrow-right me-2"></i>{% translate "Sign out" %}
3838
</a>
3939
</div>
4040
</div>

efile_app/efile/templates/efile/options.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ <h2>{% translate "View past filings" %}</h2>
110110
// Check if there's an API endpoint to retrieve saved case data
111111
const result = await apiUtils.getCaseData();
112112
if (
113+
{{ is_logged_in|lower }} &&
113114
result.success &&
114115
result.data &&
115116
Object.keys(result.data).length > 0

efile_app/efile/views/options.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from django.shortcuts import render
22

3+
from efile.api.suffolk_api_views import get_tyler_token
34
from ..utils.case_data_utils import get_case_data
45

56

@@ -11,9 +12,13 @@ def efile_options(request, jurisdiction):
1112
else:
1213
case_data = {}
1314

15+
is_logged_in = request.user.is_authenticated
16+
if not get_tyler_token(request, jurisdiction):
17+
is_logged_in = False
18+
1419
# Pass case data to template for display
1520
context = {
16-
"is_logged_in": request.user.is_authenticated,
21+
"is_logged_in": is_logged_in,
1722
"case_data": case_data,
1823
"has_case_data": bool(case_data),
1924
}

0 commit comments

Comments
 (0)