From 4db9e4565ac638246f5b9a3d1c5b0630ef5e3599 Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Wed, 4 Nov 2020 17:22:10 -0800 Subject: [PATCH 01/14] DIV-1262 - Delete the SMSESSION cookie when the user logs out - using Django instead of JS --- edivorce/apps/core/middleware/keycloak.py | 4 +--- edivorce/apps/core/static/js/main.js | 19 ------------------- edivorce/apps/core/templates/base.html | 2 +- edivorce/apps/core/urls.py | 1 + edivorce/apps/core/views/main.py | 7 +++++++ 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/edivorce/apps/core/middleware/keycloak.py b/edivorce/apps/core/middleware/keycloak.py index a4260536..5cc68814 100644 --- a/edivorce/apps/core/middleware/keycloak.py +++ b/edivorce/apps/core/middleware/keycloak.py @@ -46,7 +46,5 @@ class EDivorceKeycloakBackend(OIDCAuthenticationBackend): def keycloak_logout(request): request.session.flush() - - redirect_uri = absolutify(request, settings.FORCE_SCRIPT_NAME) - + redirect_uri = absolutify(request, settings.FORCE_SCRIPT_NAME[:-1] + '/logout') return f'{settings.KEYCLOAK_LOGOUT}?redirect_uri={redirect_uri}' diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index e6dfa495..a6b05486 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -899,27 +899,8 @@ var initializeChildRowControls = function(element) { element.find('#cancel_delete_child').on('click', function() { $('#delete_child_modal').modal('hide'); }); - - $('form#logoutForm').submit(function(e) { - deleteCookie("SMSESSION", "/", ".gov.bc.ca"); - }); }; -var deleteCookie = function(name, path, domain) { - if( getCookie(name) ) { - document.cookie = name + "=" + - ((path) ? ";path="+path:"")+ - ((domain)?";domain="+domain:"") + - ";expires=Thu, 01 Jan 1970 00:00:01 GMT"; - } -} - -var getCookie = function(name){ - return document.cookie.split(';').some(c => { - return c.trim().startsWith(name + '='); - }); -} - var populateChildInputFields = function(element) { $('.children-questions').show(); $('.children-list').hide(); diff --git a/edivorce/apps/core/templates/base.html b/edivorce/apps/core/templates/base.html index 4b3be845..a5db322b 100644 --- a/edivorce/apps/core/templates/base.html +++ b/edivorce/apps/core/templates/base.html @@ -54,7 +54,7 @@
{% if request.user.is_authenticated %} -
+ {{ request.user.display_name}}   |   {% csrf_token %} diff --git a/edivorce/apps/core/urls.py b/edivorce/apps/core/urls.py index 2efc8f7d..e4fe18e9 100644 --- a/edivorce/apps/core/urls.py +++ b/edivorce/apps/core/urls.py @@ -13,6 +13,7 @@ urlpatterns = [ path('api/documents///x//', api.DocumentView.as_view(), name='document'), url(r'^signin$', main.after_login, name="signin"), + url(r'^logout$', main.after_logout, name="logout"), url(r'^register$', main.register, name="register"), url(r'^register_sc$', main.register_sc, name="register_sc"), url(r'^overview$', main.overview, name="overview"), diff --git a/edivorce/apps/core/views/main.py b/edivorce/apps/core/views/main.py index 04042efa..0adb3c73 100644 --- a/edivorce/apps/core/views/main.py +++ b/edivorce/apps/core/views/main.py @@ -1,5 +1,6 @@ from django.conf import settings from django.contrib import messages +from django.http import HttpResponseRedirect from django.shortcuts import render, redirect from django.urls import reverse from django.contrib.auth.decorators import login_required @@ -120,6 +121,12 @@ def after_login(request): return redirect(settings.PROXY_BASE_URL + settings.FORCE_SCRIPT_NAME[:-1] + '/overview') +def after_logout(request): + response = HttpResponseRedirect(settings.PROXY_BASE_URL + settings.FORCE_SCRIPT_NAME) + response.delete_cookie(key="SMSESSION", domain=".gov.bc.ca", path="/") + return response + + @login_required @prequal_completed @intercept From 9dd47ca92b0ffa7af6650506e1f42710add948ce Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Thu, 5 Nov 2020 09:09:25 -0800 Subject: [PATCH 02/14] DIV-1200 - "Do you go by any other names?" field shows required field validation for fields with valid data --- edivorce/apps/core/templates/partials/alias_field.html | 8 ++++---- edivorce/apps/core/templatetags/input_field.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/edivorce/apps/core/templates/partials/alias_field.html b/edivorce/apps/core/templates/partials/alias_field.html index 14caefa4..8a11b2ea 100644 --- a/edivorce/apps/core/templates/partials/alias_field.html +++ b/edivorce/apps/core/templates/partials/alias_field.html @@ -15,19 +15,19 @@

First Name

- {% input_field type="text" name=name value=given_1 multiple="true" class="form-block response-textbox alias-given-1" %} + {% input_field type="text" name=name value=given_1 multiple="true" class="form-block response-textbox alias-other-name alias-given-1" %}

Middle Name 1

- {% input_field type="text" name=name value=given_2 multiple="true" ignore_error=True class="form-block response-textbox alias-given-2" %} + {% input_field type="text" name=name value=given_2 multiple="true" ignore_error=True class="form-block response-textbox alias-other-name alias-given-2" %}

Middle Name 2

- {% input_field type="text" name=name value=given_3 multiple="true" ignore_error=True class="form-block response-textbox alias-given-3" %} + {% input_field type="text" name=name value=given_3 multiple="true" ignore_error=True class="form-block response-textbox alias-other-name alias-given-3" %}

Last Name

- {% input_field type="text" name=name value=last_name multiple="true" class="form-block response-textbox alias-last-name" %} + {% input_field type="text" name=name value=last_name multiple="true" class="form-block response-textbox alias-other-name alias-last-name" %}
diff --git a/edivorce/apps/core/templatetags/input_field.py b/edivorce/apps/core/templatetags/input_field.py index 6c87abf9..5fc9daa4 100644 --- a/edivorce/apps/core/templatetags/input_field.py +++ b/edivorce/apps/core/templatetags/input_field.py @@ -56,7 +56,11 @@ def input_field(context, type, name='', value='', multiple='', ignore_error=Fals error = context.get(name + '_error', False) if error and not ignore_error: if 'class' in kwargs: - kwargs['class'] += ' error' + if 'alias-other-name' in kwargs.get('class', ''): # DIV-1200 + if not value: + kwargs['class'] += ' error' + else: + kwargs['class'] += ' error' else: kwargs['class'] = 'error' From 9b692610de3786eb9ea501b18f7f0e7d78285473 Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Thu, 5 Nov 2020 09:36:47 -0800 Subject: [PATCH 03/14] DIV-1158 - UX issue when asking for names ("Your spouse" / "Your information" screens) --- edivorce/apps/core/templates/question/02_claimant.html | 7 +++++-- edivorce/apps/core/templates/question/03_respondent.html | 9 +++++---- edivorce/fixtures/Question.json | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/edivorce/apps/core/templates/question/02_claimant.html b/edivorce/apps/core/templates/question/02_claimant.html index 905196f3..09e0deaf 100644 --- a/edivorce/apps/core/templates/question/02_claimant.html +++ b/edivorce/apps/core/templates/question/02_claimant.html @@ -39,7 +39,10 @@
-

If either of you has had a legal name change since you were married, put that new name on your form, and bring along a copy of the change of name certificate when you file your documents.

+

+ The name written here must match the name that is on your marriage certificate. If you have changed your + legal name since you were married, add it to the section below titled “Do you go by any other names”. +

@@ -57,7 +60,7 @@
-

Do you go by any other names?{% if any_other_name_you_error %}{% include 'partials/required.html' %}{% endif %}

+

Do you go by any other names?{% include "partials/optional.html" %}

@@ -64,7 +65,7 @@
-

Does your spouse go by any other names?{% if any_other_name_spouse_error %}{% include 'partials/required.html' %}{% endif %}

+

Does your spouse go by any other names?{% include "partials/optional.html" %}

-

Do you go by any other names?{% include "partials/optional.html" %}

+

Do you go by any other names?{% if any_other_name_you_error %}{% include 'partials/required.html' %}{% endif %}

-

Does your spouse go by any other names?{% include "partials/optional.html" %}

+

Does your spouse go by any other names?{% if any_other_name_spouse_error %}{% include 'partials/required.html' %}{% endif %}