Browse Source

fixed proxy url error in ajax requests

pull/160/head
Mike Olund 8 years ago
parent
commit
7fd9dcb59b
3 changed files with 10 additions and 1 deletions
  1. +6
    -0
      edivorce/apps/core/middleware/bceid_middleware.py
  2. +1
    -1
      edivorce/apps/core/static/js/ajax.js
  3. +3
    -0
      edivorce/apps/core/templates/base.html

+ 6
- 0
edivorce/apps/core/middleware/bceid_middleware.py View File

@ -1,5 +1,7 @@
import uuid
from django.conf import settings
class BceidUser(object):
def __init__(self, guid, first_name, last_name, type, is_authenticated):
@ -12,6 +14,10 @@ class BceidUser(object):
class BceidMiddleware(object):
def process_request(self, request):
# make the FORCE_SCRIPT_NAME available in templates
request.proxy_root_path = settings.FORCE_SCRIPT_NAME
# todo: Make sure the request is coming from the justice proxy (via IP/host check)
# 1. Real BCeID user


+ 1
- 1
edivorce/apps/core/static/js/ajax.js View File

@ -49,7 +49,7 @@ var getCSRFToken = function () {
// Ajax called when user update their response
var ajaxCall = function(question, value){
// var url = $(location).attr('href');
var url = $(location).attr('origin') + '/api/response';
var url = $(location).attr('origin') + window.sm_base_url + 'api/response';
// add CSRF_TOKEN to POST
var csrf_token = getCSRFToken();


+ 3
- 0
edivorce/apps/core/templates/base.html View File

@ -21,6 +21,9 @@
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<script>window.html5 || document.write('<script src="js/vendor/html5shiv.js"><\/script>')</script>
<![endif]-->
<script>
window.sm_base_url = '{{ request.proxy_root_path }}';
</script>
</head>
<body>


Loading…
Cancel
Save