Skip to content

Commit 5104975

Browse files
committed
Absolute path with baseURL
1 parent 8def5f5 commit 5104975

File tree

5 files changed

+27
-22
lines changed

5 files changed

+27
-22
lines changed

js/GroupKeys.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,25 @@
22
(function ($) {
33
// Jquery onload function.
44
$(document).ready(function(){
5+
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
6+
57
/**
68
* Method to return the csrf token
79
*/
810
function getCsrfToken() {
911
return $.ajax({
1012
type: "GET",
11-
url: "/rest/session/token",
13+
url: baseURL + "/rest/session/token",
1214
async: false
1315
}).responseText;
1416
}
17+
1518
var routeName = drupalSettings.client_side_file_crypto.routeName;
1619
if(routeName != 'client_side_file_crypto.newKeys')
17-
$.get("/publicKey/?_format=json", function(xhr_pub_key){
20+
$.get(baseURL + "/publicKey/?_format=json", function(xhr_pub_key){
1821
var encrypt = new JSEncrypt();
1922
encrypt.setPublicKey(xhr_pub_key['publicKey']);
20-
$.get("/groupKeys?_format=json", function(pending_roles){
23+
$.get(baseURL + "/groupKeys?_format=json", function(pending_roles){
2124
var pending_role_names = pending_roles['roleNames'];
2225
if(pending_role_names.length>0){
2326
pending_role_names.forEach(function(role_name) {
@@ -30,7 +33,7 @@
3033
"userID" : pending_roles['userID'],
3134
};
3235
jQuery.ajax({
33-
url: '../accessKey/?_format=json',
36+
url: baseURL + '/accessKey/?_format=json',
3437
method: 'POST',
3538
headers: {
3639
'Content-Type': 'application/hal+json',

js/decrypt.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
$(document).ready(function(){
66
var uid = drupalSettings.client_side_file_crypto.uid;
7+
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
78
var file = null;
89
var encryptedFileList = $(".node__content div[property='schema:text']");
910

1011
//Method to return the csrf token.
1112
function getCsrfToken() {
1213
return $.ajax({
1314
type: "GET",
14-
url: "/rest/session/token",
15+
url: baseURL + "/rest/session/token",
1516
async: false
1617
}).responseText;
1718
}
@@ -20,7 +21,7 @@
2021
function getAccessKey(roleName){
2122
var xhrData = $.ajax({
2223
type: "GET",
23-
url: "/accessKey/?_format=json",
24+
url: baseURL + "/accessKey/?_format=json",
2425
async: false
2526
}).responseText;
2627
var accessKeysObject = JSON.parse(xhrData);
@@ -108,7 +109,7 @@
108109

109110
//Fetching the file list and appending to the DOM
110111
if(nodeID != -1){
111-
$.get("../fileMetadata/" + nodeID + "/?_format=json", function(fileMetaData){
112+
$.get(baseURL + "/fileMetadata/" + nodeID + "/?_format=json", function(fileMetaData){
112113
if(fileMetaData.fileCount != 0){
113114
$(".node__content div[property='schema:text']").append("<h3 class='title'>Encrypted Files</h3>");
114115
var files = fileMetaData.files;

js/encrypt.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
// Jquery wrapper for drupal to avoid conflicts between libraries.
22
(function ($) {
3+
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
34
/**
45
* Method to return the csrf token
56
*/
67
function getCsrfToken() {
78
return $.ajax({
89
type: "GET",
9-
url: "/rest/session/token",
10-
async: false
10+
url: baseURL + "/rest/session/token",
11+
async: false
1112
}).responseText;
1213
}
1314

1415
var file = undefined;
1516
$(document).ready(function(){
16-
$(".node-form").attr("action", "/node/add/"+$(".node-form").attr('data-drupal-selector').split("-")[1]);
17+
$(".node-form").attr("action", "/node/add/" + $(".node-form").attr('data-drupal-selector').split("-")[1]);
1718
var uid = drupalSettings.client_side_file_crypto.uid;
1819
$("#cryptoFields").change(function(e){
1920
e.preventDefault();
2021
file = e.target.files[0];
2122
var role = $("#roleSelect").val();
2223
var fileName = "encrypted_" + file.name;
23-
$.get("/accessKey/?_format=json", function(xhrAccessKey){
24+
$.get(baseURL + "/accessKey/?_format=json", function(xhrAccessKey){
2425
var privateKey = localStorage.getItem("csfcPrivKey_" + uid);
2526
var decrypt = new JSEncrypt();
2627
decrypt.setPrivateKey(privateKey);
@@ -37,7 +38,7 @@
3738
formData.append('csfcRoleName', role);
3839

3940
$.ajax({
40-
url: '/encryptedFileUpload',
41+
url: baseURL + '/encryptedFileUpload',
4142
data: formData,
4243
processData: false,
4344
contentType: false,

js/pubkeyGen.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Jquery wrapper for drupal to avoid conflicts between libraries.
22
(function ($) {
3+
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
34

45
// Jquery onload function.
56
function download(filename, text) {
@@ -22,7 +23,7 @@
2223
function getCsrfToken() {
2324
return $.ajax({
2425
type: "GET",
25-
url: "/rest/session/token",
26+
url: baseURL + "/rest/session/token",
2627
async: false
2728
}).responseText;
2829
}
@@ -31,7 +32,7 @@
3132
function getPublicKey(uid){
3233
var xhrData = $.ajax({
3334
type: "GET",
34-
url: "/publicKey/"+uid+"/?_format=json",
35+
url: baseURL + "/publicKey/" + uid + "/?_format=json",
3536
async: false
3637
}).responseText;
3738
var pubKeyObject = JSON.parse(xhrData);
@@ -40,7 +41,6 @@
4041

4142
$(document).ready(function(){
4243
var uid = drupalSettings.client_side_file_crypto.uid;
43-
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
4444
var ExistingPubKey = getPublicKey(uid);
4545
if(!ExistingPubKey && !localStorage.getItem("csfcPrivKey_" + uid)){
4646
//default pubkey size for now = 1024
@@ -57,7 +57,7 @@
5757
};
5858

5959
jQuery.ajax({
60-
url: '/publicKey?_format=json',
60+
url: baseURL + '/publicKey?_format=json',
6161
method: 'POST',
6262
headers: {
6363
'Content-Type': 'application/hal+json',
@@ -69,11 +69,11 @@
6969
});
7070
$("#key-status").text("Key generated.");
7171
$("#more-info").text("A private key has been downloaded to your computer that you will need to keep to keep safe in case your browser data gets wiped and to access the encrypted files on other devices. In case you need to restore the keys you can do it at /restoreKeys");
72-
$("#more-info").append("<br><font color='#FF0000'>Key requests have been put up for each of your roles.<br>You will only be able to access the encrypted features once another user with the keys logs in and generated keys for you.<br>You will need to wait until then. </font><br><a href='"+baseURL+"/user/keyGenRedirect'>Go to home.</a>");
72+
$("#more-info").append("<br><font color='#FF0000'>Key requests have been put up for each of your roles.<br>You will only be able to access the encrypted features once another user with the keys logs in and generated keys for you.<br>You will need to wait until then. </font><br><a href='" +baseURL + "/user/keyGenRedirect'>Go to home.</a>");
7373
download('PrivateKey.pem', privateKey);
7474
} else {
7575
$("#key-status").text("Key already generated!");
76-
$("#more-info").html("A key pair has already been generated for this user.<br><a href='"+baseURL+"'>Go to home.</a>");
76+
$("#more-info").html("A key pair has already been generated for this user.<br><a href='" + baseURL + "'>Go to home.</a>");
7777
}
7878
});
7979
$(document).ajaxStop(function() {

js/updatePendingKeys.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
(function ($) {
33
// Jquery onload function.
44
$(document).ready(function(){
5+
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
56

67
/**
78
* Method to return the csrf token
89
*/
910
function getCsrfToken() {
1011
return $.ajax({
1112
type: "GET",
12-
url: "/rest/session/token",
13+
url: baseURL + "/rest/session/token",
1314
async: false
1415
}).responseText;
1516
}
1617

1718
var uid = drupalSettings.client_side_file_crypto.uid;
18-
var baseURL = drupalSettings.client_side_file_crypto.baseURL;
1919
var routeName = drupalSettings.client_side_file_crypto.routeName;
2020
var blockedRoutes = [
2121
//'client_side_file_crypto.postLogin',
@@ -29,7 +29,7 @@
2929
}
3030
var privateKey = localStorage.getItem("csfcPrivKey_" + uid);
3131
var encrypt = new JSEncrypt();
32-
$.get("/accessKey/pending?_format=json", function(pendingKeysJSON){
32+
$.get(baseURL + "/accessKey/pending?_format=json", function(pendingKeysJSON){
3333
var decrypt = new JSEncrypt();
3434
decrypt.setPrivateKey(privateKey);
3535
pendingKeys = pendingKeysJSON['accessKeys'];
@@ -46,7 +46,7 @@
4646
"userID" : accessKey['uid'],
4747
};
4848
jQuery.ajax({
49-
url: '/accessKey/?_format=json',
49+
url: baseURL + '/accessKey/?_format=json',
5050
method: 'POST',
5151
headers: {
5252
'Content-Type': 'application/hal+json',

0 commit comments

Comments
 (0)