-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4574 add session check redirection (#4636)
* Added check in preprocessors for session status implimented modal in header.html and changed mixin to use session check. * Updated to handle request structure * Updated format with isort and black * Removed unused import * Updated url reference for django * refactored to simplify control logic and updated tests to handle new test case * Removed unused import * Refactored modals and js into seperate files * Added custom exceptions, middlware handlers * Updated static pathing for js file * Updated tests to handle new exception and realigned naming * Fixed formatting * Removed unused import * Fixed formatting * Removed unused helper function
- Loading branch information
1 parent
e84353c
commit f0bd3ff
Showing
16 changed files
with
192 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class SessionExpiredException(Exception): | ||
def __init__(self, message="Your session has expired. Please log in again."): | ||
self.message = message | ||
super().__init__(self.message) | ||
|
||
|
||
class SessionWarningException(Exception): | ||
def __init__(self, message="Your session is about to expire."): | ||
self.message = message | ||
super().__init__(self.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
|
||
const modalTrigger = document.createElement("a"); | ||
modalTrigger.setAttribute("href", `#session-expired-modal`); | ||
modalTrigger.setAttribute("data-open-modal", ""); | ||
modalTrigger.setAttribute("aria-controls", 'session-expired-modal'); | ||
modalTrigger.setAttribute("role", "button"); | ||
modalTrigger.className = "sign-in display-flex flex-row"; | ||
document.body.appendChild(modalTrigger); | ||
|
||
setTimeout(() => { | ||
modalTrigger.click(); | ||
modalTrigger.remove(); | ||
}, 100); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document.addEventListener("DOMContentLoaded", function () { | ||
const modalTrigger = document.createElement("a"); | ||
modalTrigger.setAttribute("href", `#session-warning-modal`); | ||
modalTrigger.setAttribute("data-open-modal", ""); | ||
modalTrigger.setAttribute("aria-controls", 'session-warning-modal'); | ||
modalTrigger.setAttribute("role", "button"); | ||
modalTrigger.className = "sign-in display-flex flex-row"; | ||
document.body.appendChild(modalTrigger); | ||
|
||
setTimeout(() => { | ||
modalTrigger.click(); | ||
modalTrigger.remove(); | ||
}, 100); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,4 @@ | |
</div> | ||
</div> | ||
</section> | ||
{% include "includes/nav_primary.html" %} | ||
{% include "includes/nav_primary.html" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{% load static %} | ||
<script src="{% static 'compiled/js/session-expired-modal.js' %}"></script> | ||
<div class="usa-modal" | ||
id="session-expired-modal" | ||
aria-labelledby="session-expired-modal-heading" | ||
aria-describedby="session-expired-modal-description"> | ||
<div class="usa-modal__content"> | ||
<div class="usa-modal__main"> | ||
<h2 class="usa-modal__heading" id="session-expire-modal-heading">Your session has expired</h2> | ||
<div id="session-expired-modal-description"> | ||
<p class="text-base">To protect your account, you have been automatically signed out.</p> | ||
</div> | ||
<div class="usa-modal__footer"> | ||
<ul class="usa-button-group"> | ||
<li class="usa-button-group__item"> | ||
<a href="{% url 'login' %}?next={{ request.path }}"> | ||
<button type="button" | ||
class="usa-button sign-in-button" | ||
id="sign-in-expired" | ||
data-close-modal>Authenticate with Login.gov</button> | ||
</a> | ||
</li> | ||
<li class="usa-button-group__item"> | ||
<a href="{% url 'Home' %}"> | ||
<button type="button" | ||
class="usa-button usa-button--unstyled padding-105 text-center" | ||
data-close-modal>Cancel</button> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% load static %} | ||
<script src="{% static 'compiled/js/session-warning-modal.js' %}"></script> | ||
<div class="usa-modal usa-modal" | ||
id="session-warning-modal" | ||
aria-labelledby="session-warning-heading" | ||
aria-describedby="session-warning-description"> | ||
<div class="usa-modal__content"> | ||
<div class="usa-modal__main"> | ||
<h2 class="usa-modal__heading" id="session-warning-heading">You will be signed out soon</h2> | ||
<div id="session-warning-description"> | ||
<p class="text-base">Your session is about to expire due to inactivity.</p> | ||
<li class="usa-icon-list__item"> | ||
<div class="usa-icon-list__icon text-warning-dark"> | ||
<svg class="usa-icon" aria-hidden="true" role="img"> | ||
{% uswds_sprite "error" %} | ||
</svg> | ||
</div> | ||
<div class="usa-icon-list__content"> | ||
Time Remaining: {{ formatted_time }} | ||
</div> | ||
</li> | ||
</div> | ||
<div class="usa-modal__footer"> | ||
<ul class="usa-button-group"> | ||
<li class="usa-button-group__item"> | ||
<a href="#"> | ||
<button type="button" | ||
class="usa-button sign-in-button" | ||
id="continue-session" | ||
data-close-modal>Continue Session</button> | ||
</a> | ||
</li> | ||
<li class="usa-button-group__item"> | ||
<a href="{% url 'logout' %}"> | ||
<button type="button" | ||
class="usa-button usa-button--unstyled padding-105 text-center" | ||
data-close-modal>Sign out now</button> | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
<button class="usa-button usa-modal__close" | ||
aria-label="Close this window" | ||
data-close-modal> | ||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img"> | ||
{% uswds_sprite "close" %} | ||
</svg> | ||
</button> | ||
</div> | ||
</div> |