From c41ba4d0fc9710dc46af4c39c343c4b5bc734ee3 Mon Sep 17 00:00:00 2001 From: Michael Olund Date: Wed, 4 Nov 2020 16:42:37 -0800 Subject: [PATCH] DIV-1262 - Delete the SMSESSION cookie when the user logs out --- edivorce/apps/core/static/js/main.js | 20 ++++++++++++++++++++ edivorce/apps/core/templates/base.html | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/edivorce/apps/core/static/js/main.js b/edivorce/apps/core/static/js/main.js index 050091d3..e6dfa495 100755 --- a/edivorce/apps/core/static/js/main.js +++ b/edivorce/apps/core/static/js/main.js @@ -899,8 +899,27 @@ 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(); @@ -1312,3 +1331,4 @@ var updateChildSupportActQuestion = function (wantChildSupport) { } } }; + diff --git a/edivorce/apps/core/templates/base.html b/edivorce/apps/core/templates/base.html index a5db322b..4b3be845 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 %}