Merged PR 894: use sql server for auth and cascade auth id to storage account
Related work items: #7902
This commit is contained in:
+14
-5
@@ -77,15 +77,24 @@ GOOGLE_MAP_API_KEY = AIzaSyCzeVrHt544bp_72YCFkw21eDsmI2JEsQo
|
||||
|
||||
|
||||
//Next Auth vars
|
||||
EMAIL_SERVER_HOST=smtp.sendgrid.net
|
||||
//EMAIL_SERVER_HOST=smtp.sendgrid.net
|
||||
//EMAIL_SERVER_PORT=465
|
||||
//EMAIL_SERVER_USER=apikey
|
||||
//EMAIL_SERVER_PASSWORD=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
|
||||
//EMAIL_FROM=rob@rdbsolutions.co.uk
|
||||
|
||||
|
||||
EMAIL_SERVER_HOST=rdbdigital.com
|
||||
EMAIL_SERVER_PORT=465
|
||||
EMAIL_SERVER_USER=apikey
|
||||
EMAIL_SERVER_PASSWORD=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
|
||||
EMAIL_FROM=rob@rdbsolutions.co.uk
|
||||
EMAIL_SERVER_USER=rob@rdbdigital.com
|
||||
EMAIL_SERVER_PASSWORD=!Sky9fish2020
|
||||
EMAIL_FROM=no-reply@rdbdigital.com
|
||||
|
||||
NEXTAUTH_URL=http://localhost:3000
|
||||
NEXTAUTH_URL_INTERNAL=http://localhost:3000
|
||||
DATABASE_URL=mysql://nextAuthAdmin:!Sky9fish1972@77.68.17.157:3306/nextauthDB?synchronise=true
|
||||
//DATABASE_URL=mysql://nextAuthAdmin:!Sky9fish1972@77.68.17.157:3306/nextauthDB?synchronise=true
|
||||
DATABASE_URL = sqlserver://pedw-dev-test-sql-svr.database.windows.net:1433;database=PEDWDev;user=RobBondSQL;password=GhWKr62F5sQ69dZx;encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;authentication=ActiveDirectoryPassword
|
||||
|
||||
SECRET=SuperSecret
|
||||
|
||||
|
||||
|
||||
+70
-31
@@ -14,7 +14,7 @@ const STORAGE_CONTAINER = process.env.AZURE_PEDW_CONTAINER;
|
||||
export const createContainer = async (containerName) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
containerName = containerName.toLowerCase();
|
||||
//containerName = containerName.toLowerCase();
|
||||
|
||||
// console.log(
|
||||
// "container name:",
|
||||
@@ -40,6 +40,8 @@ export const createContainer = async (containerName) => {
|
||||
// console.log(`- ${container.name}`);
|
||||
// }
|
||||
|
||||
console.log("\n//////////////////\n container name :", containerName);
|
||||
|
||||
return containerName;
|
||||
};
|
||||
|
||||
@@ -53,7 +55,7 @@ export const getContainers = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getBlobs = async (containerName) => {
|
||||
export const getBlobs = async (containerName, casefolderID) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
@@ -65,14 +67,14 @@ export const getBlobs = async (containerName) => {
|
||||
|
||||
const blobObj = [];
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: "files/",
|
||||
prefix: casefolderID + "/files/",
|
||||
})) {
|
||||
let blobDocumentType = blob.name
|
||||
.split("/")[1]
|
||||
.slice(0, blob.name.split("/")[1].indexOf("_"));
|
||||
.split("/")[2]
|
||||
.slice(0, blob.name.split("/")[2].indexOf("_"));
|
||||
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"name": blob.name.split("/")[2],
|
||||
"path": blob.name,
|
||||
"documentType": blobDocumentType,
|
||||
"versionId": blob.versionId,
|
||||
@@ -80,28 +82,50 @@ export const getBlobs = async (containerName) => {
|
||||
"contentLength": blob.properties.contentLength,
|
||||
"contentType": blob.contentType,
|
||||
"lastModified": blob.properties.lastModified,
|
||||
"filepath":
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[2],
|
||||
"hashedfilepath": hashAPIPath(
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
blob.name.split("/")[2]
|
||||
),
|
||||
"deletepath":
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[2],
|
||||
"hasheddeletepath": hashAPIPath(
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
blob.name.split("/")[2]
|
||||
),
|
||||
"hashgetblobs": hashAPIPath(
|
||||
"/api/file/getbloblist?container=" + containerName.toLowerCase()
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID
|
||||
),
|
||||
});
|
||||
}
|
||||
console.log("blobObj:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
|
||||
export const createBlob = async (formContent, containerName) => {
|
||||
export const createBlob = async (formContent, containerName, caseref) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
@@ -109,21 +133,19 @@ export const createBlob = async (formContent, containerName) => {
|
||||
creds
|
||||
);
|
||||
|
||||
formContent = JSON.parse(formContent);
|
||||
let caseID = formContent.pinswg_name;
|
||||
|
||||
const content = JSON.stringify(formContent);
|
||||
const blobName =
|
||||
formContent.pinswg_name + "_" + new Date().getTime() + ".json";
|
||||
const blobName = caseID + "/" + caseID + ".json";
|
||||
|
||||
console.log("blobName:", blobName);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
|
||||
const uploadBlobResponse = await blockBlobClient.upload(
|
||||
content,
|
||||
Buffer.byteLength(content)
|
||||
);
|
||||
|
||||
// console.log("Blobs:");
|
||||
// for await (const blob of containerClient.listBlobsByHierarchy("/")) {
|
||||
// console.log(`- ${blob.name}`);
|
||||
// }
|
||||
|
||||
return formContent.pinswg_name;
|
||||
};
|
||||
|
||||
@@ -159,11 +181,13 @@ export const uploadFile = async (formContent, containerName, foldername) => {
|
||||
const files = formContent;
|
||||
|
||||
//console.log(...formContent);
|
||||
//console.log("files...", files, files.length);
|
||||
console.log("files...", files, Object.keys(files).length, foldername);
|
||||
|
||||
for (const prop in files) {
|
||||
//console.log(`files[${prop}] = ${files[prop][0].size}`);
|
||||
const blobName = "files/" + files[prop][0].fieldName;
|
||||
console.log(`files[${prop}] = ${files[prop][0].size}`);
|
||||
const blobName = foldername + "/files/" + files[prop][0].fieldName;
|
||||
|
||||
console.log(blobName);
|
||||
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
|
||||
const uploadBlobResponse = await blockBlobClient.uploadFile(
|
||||
files[prop][0].path,
|
||||
@@ -185,14 +209,18 @@ export const downloadFile = async (containerName, blobName) => {
|
||||
creds
|
||||
);
|
||||
|
||||
const blobClient = containerClient.getBlobClient("files/" + blobName);
|
||||
const blobClient = containerClient.getBlobClient(blobName);
|
||||
const downloadedBlob = await blobClient.download(0);
|
||||
|
||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||
return downloaded;
|
||||
};
|
||||
|
||||
export const downloadProgressFile = async (containerName, blobName) => {
|
||||
export const downloadProgressFile = async (
|
||||
containerName,
|
||||
blobName,
|
||||
casefolderID
|
||||
) => {
|
||||
//console.log.apply(containerName, blobName);
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
@@ -202,6 +230,7 @@ export const downloadProgressFile = async (containerName, blobName) => {
|
||||
);
|
||||
|
||||
const blobClient = containerClient.getBlobClient(blobName);
|
||||
console.log("herher:", containerName, blobName, casefolderID);
|
||||
const downloadedBlob = await blobClient.download(0);
|
||||
|
||||
const downloaded = await streamToBuffer(downloadedBlob.readableStreamBody);
|
||||
@@ -221,7 +250,7 @@ const streamToBuffer = async (readableStream) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getProgressBlobs = async (containerName) => {
|
||||
export const getProgressBlobs = async (containerName, caseReference) => {
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const containerClient = new ContainerClient(
|
||||
@@ -231,8 +260,11 @@ export const getProgressBlobs = async (containerName) => {
|
||||
|
||||
containerClient.createIfNotExists();
|
||||
|
||||
console.log("thisi s the caasefolder:", caseReference);
|
||||
let blobObj = [];
|
||||
for await (const blob of containerClient.listBlobsFlat()) {
|
||||
for await (const blob of containerClient.listBlobsFlat({
|
||||
prefix: caseReference + "/" + caseReference + ".json",
|
||||
})) {
|
||||
blobObj.push({
|
||||
"name": blob.name.split("/")[1],
|
||||
"path": blob.name,
|
||||
@@ -243,18 +275,25 @@ export const getProgressBlobs = async (containerName) => {
|
||||
"lastModified": blob.properties.lastModified,
|
||||
"hashedfilepath": hashAPIPath(
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
caseReference +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
),
|
||||
"hasheddeletepath": hashAPIPath(
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
caseReference +
|
||||
"&blobname=" +
|
||||
blob.name.split("/")[1]
|
||||
),
|
||||
"hashgetblobs": hashAPIPath(
|
||||
"/api/file/getbloblist?container=" + containerName.toLowerCase()
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
caseReference
|
||||
),
|
||||
});
|
||||
}
|
||||
@@ -265,7 +304,7 @@ export const getProgressBlobs = async (containerName) => {
|
||||
},
|
||||
]).reverse()[0];
|
||||
|
||||
console.log(blobObj.path);
|
||||
console.log("blobObj:", blobObj);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
|
||||
+61
-14
@@ -26,7 +26,7 @@ const WEBAPI_URL =
|
||||
|
||||
export const consoleLogger = (err) => {
|
||||
var errStr =
|
||||
"///////\nServer Error " +
|
||||
"\n\n/////////////////////////////////////////////////\nServer Error " +
|
||||
"\n" +
|
||||
err.response.status +
|
||||
" : " +
|
||||
@@ -35,7 +35,7 @@ export const consoleLogger = (err) => {
|
||||
err.response.config.url +
|
||||
"\nRequest Time: " +
|
||||
err.response.headers.date +
|
||||
"\n///////";
|
||||
"\n/////////////////////////////////////////////////\n\n";
|
||||
return errStr;
|
||||
};
|
||||
|
||||
@@ -132,6 +132,7 @@ export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
||||
};
|
||||
|
||||
export const hashAPIPath = (queryPath) => {
|
||||
console.log(queryPath);
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
queryPath,
|
||||
CryptoJS.enc.Hex.parse(WORDKEY)
|
||||
@@ -602,7 +603,7 @@ export const getAppealID = (
|
||||
// getFormCollection(updateFormCollection)
|
||||
// )
|
||||
|
||||
let formCollectionName = getFormCollection(updateFormCollection);
|
||||
//let formCollectionName = getFormCollection(updateFormCollection);
|
||||
//console.log(formCollectionName);
|
||||
return axios
|
||||
.get(
|
||||
@@ -617,12 +618,12 @@ export const getAppealID = (
|
||||
const result = Object.entries(res.data.value[0]).filter(
|
||||
([key]) => !key.startsWith("_")
|
||||
)[0][1];
|
||||
|
||||
console.log("result:", res.data);
|
||||
var appealID = result;
|
||||
return appealID;
|
||||
})
|
||||
.catch((error) => {
|
||||
//console.log("API call error", error);
|
||||
console.log("API call error", error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -915,7 +916,7 @@ export const updateCase = async (
|
||||
var config = {
|
||||
method: "post",
|
||||
url: queryUrl,
|
||||
data: data,
|
||||
data: updateBody,
|
||||
};
|
||||
|
||||
//console.log(data);
|
||||
@@ -1040,12 +1041,19 @@ export const createAccount = (formValues) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const uploadFiles = async (formValues, filesObj, uploadhash) => {
|
||||
export const uploadFiles = async (
|
||||
formValues,
|
||||
filesObj,
|
||||
containerID,
|
||||
casefolderID
|
||||
) => {
|
||||
let files = filesObj;
|
||||
|
||||
//console.log(formValues);
|
||||
var formData = new FormData();
|
||||
formData.append("appealData", JSON.stringify(formValues));
|
||||
formData.append("containerID", containerID);
|
||||
formData.append("casefolderID", casefolderID);
|
||||
|
||||
// files.forEach((file) => formData.append("files", file));
|
||||
|
||||
@@ -1076,15 +1084,19 @@ export const uploadFiles = async (formValues, filesObj, uploadhash) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const getFilesFromBlob = (containerName) => {
|
||||
export const getFilesFromBlob = (containerName, casefolderID) => {
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL +
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
hashAPIPath(
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName.toLowerCase()
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID
|
||||
)
|
||||
)
|
||||
.then((res) => {
|
||||
@@ -1096,12 +1108,18 @@ export const getFilesFromBlob = (containerName) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getFilesFromBlobHashed = (containerName, getblobshash) => {
|
||||
export const getFilesFromBlobHashed = (
|
||||
containerName,
|
||||
getblobshash,
|
||||
casefolderID
|
||||
) => {
|
||||
return axios
|
||||
.get(
|
||||
BASE_URL +
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
getblobshash
|
||||
)
|
||||
.then((res) => {
|
||||
@@ -1113,12 +1131,19 @@ export const getFilesFromBlobHashed = (containerName, getblobshash) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const deleteBlob = async (containerName, blobName, deleteblobhash) => {
|
||||
export const deleteBlob = async (
|
||||
containerName,
|
||||
blobName,
|
||||
deleteblobhash,
|
||||
casefolderID
|
||||
) => {
|
||||
try {
|
||||
const res = await axios.get(
|
||||
BASE_URL +
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blobName +
|
||||
deleteblobhash
|
||||
@@ -1154,3 +1179,25 @@ export const downloadBlob = (containerName, blobName) => {
|
||||
console.log("this serror", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getProgressFromBlob = async (containerName, casereference) => {
|
||||
console.log("cont:", containerName);
|
||||
try {
|
||||
const res = await axios.get(
|
||||
BASE_URL +
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casereference +
|
||||
hashAPIPath(
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casereference
|
||||
)
|
||||
);
|
||||
return res.data;
|
||||
} catch (error) {
|
||||
console.log("this serror", error);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1255,6 +1255,7 @@ export function FileUploadField(props) {
|
||||
hint={props.hint}
|
||||
fileList={props.fileList}
|
||||
setFilesForAppeal={props.setFilesForAppeal}
|
||||
containerID={props.containerID}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
@@ -1459,15 +1460,18 @@ const RenderFileUpload = (field) => {
|
||||
containerName,
|
||||
blobName,
|
||||
deleteblobhash,
|
||||
getblobshash
|
||||
getblobshash,
|
||||
casefolderID
|
||||
) => {
|
||||
//console.log(containerName, blobName, deleteblobhash);
|
||||
deleteBlob(containerName, blobName, deleteblobhash)
|
||||
deleteBlob(containerName, blobName, deleteblobhash, casefolderID)
|
||||
.then((data) => data)
|
||||
.then(() => {
|
||||
getFilesFromBlobHashed(containerName, getblobshash).then(
|
||||
(newfilelist) => field.setFilesForAppeal(newfilelist)
|
||||
);
|
||||
getFilesFromBlobHashed(
|
||||
containerName,
|
||||
getblobshash,
|
||||
casefolderID
|
||||
).then((newfilelist) => field.setFilesForAppeal(newfilelist));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1543,10 +1547,11 @@ const RenderFileUpload = (field) => {
|
||||
className="govuk-summary-list__actionLink watched_link govuk-!-margin-right-5 govuk-!-text-align-left"
|
||||
onClick={() => {
|
||||
deleteThisBlob(
|
||||
field.ticketnumber,
|
||||
field.containerID,
|
||||
blob.name,
|
||||
blob.hasheddeletepath,
|
||||
blob.hashgetblobs
|
||||
blob.hashgetblobs,
|
||||
field.ticketnumber
|
||||
);
|
||||
}}
|
||||
title="Remove this file"
|
||||
@@ -1565,7 +1570,9 @@ const RenderFileUpload = (field) => {
|
||||
scroll={false}
|
||||
href={
|
||||
"/api/file/downloadblob?container=" +
|
||||
field.ticketnumber.toLowerCase() +
|
||||
field.containerID +
|
||||
"&casefolderID=" +
|
||||
field.ticketnumber +
|
||||
"&blobname=" +
|
||||
blob.name +
|
||||
blob.hashedfilepath
|
||||
|
||||
@@ -21,7 +21,7 @@ const MyPortal = (props) => {
|
||||
const { locale } = router;
|
||||
|
||||
const handleLogout = () => {
|
||||
console.log("////////////\n" + "logout" + "\n////////////");
|
||||
console.info("////////////\n" + "logout" + "\n////////////");
|
||||
destroyCookie({}, "pinsUser"),
|
||||
window.localStorage.clear(),
|
||||
//router.replace(props.ggLogout);
|
||||
|
||||
@@ -189,6 +189,10 @@ export default function BuildField(props) {
|
||||
setFilesForAppeal={
|
||||
props.props.props.setFilesForAppeal
|
||||
}
|
||||
containerID={
|
||||
props.props.props.props.accountDetails
|
||||
.containerID
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -111,13 +111,23 @@ let BuildSection = (props) => {
|
||||
|
||||
//console.log(fileListObj);
|
||||
|
||||
console.log(
|
||||
"\n////////////////////////\n upload files:",
|
||||
props.props.accountDetails.containerID
|
||||
);
|
||||
|
||||
var dataObj = values;
|
||||
|
||||
for (let key in dataObj) {
|
||||
_.includes(key, "pinswg_fileUpload") == true && delete dataObj[key];
|
||||
}
|
||||
|
||||
uploadFiles(dataObj, fileListObj).then((data) => {
|
||||
uploadFiles(
|
||||
dataObj,
|
||||
fileListObj,
|
||||
props.props.accountDetails.containerID,
|
||||
props.props.appealType.caseReference.ticketnumber
|
||||
).then((data) => {
|
||||
//console.log("hello", data);
|
||||
|
||||
return data;
|
||||
|
||||
@@ -408,35 +408,54 @@ const DNSSearchResults = (props) => {
|
||||
)[0]
|
||||
: ""
|
||||
: ""}
|
||||
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddressline1
|
||||
: ""}
|
||||
<br />
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddressline1 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline2"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddressline2
|
||||
: ""}
|
||||
<br />
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline2"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddressline2 !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddresstown
|
||||
: ""}
|
||||
<br />
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresstown"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddresstown !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
)
|
||||
? detailsObj.pinswg_siteaddresscounty
|
||||
: ""}
|
||||
<br />
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddresscounty"
|
||||
) &&
|
||||
detailsObj.pinswg_siteaddresscounty !=
|
||||
null && <br />}
|
||||
{_.has(
|
||||
detailsObj,
|
||||
"pinswg_siteaddressline1"
|
||||
|
||||
@@ -39,7 +39,7 @@ const TimeOut = (props) => {
|
||||
};
|
||||
|
||||
const handleLogout = () => {
|
||||
console.log("////////////\n" + "logout" + "\n////////////");
|
||||
console.info("////////////\n" + "logout" + "\n////////////");
|
||||
destroyCookie({}, "pinsUser"),
|
||||
window.localStorage.clear(),
|
||||
signOut({ callbackUrl: "/logout" });
|
||||
|
||||
@@ -11,6 +11,7 @@ module.exports = {
|
||||
"pages": {
|
||||
"*": ["common", "newappeal", "search"],
|
||||
"/": ["common", "home"],
|
||||
"/error": ["common", "home", "myportal"],
|
||||
"/myportal": ["myportal", "common", "home"],
|
||||
"/myportal/viewall": ["search"],
|
||||
"/myportal/advancedsearch": ["search", "myportal"],
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@
|
||||
"@azure/storage-blob": "^12.10.0",
|
||||
"@googlemaps/react-wrapper": "^1.1.24",
|
||||
"@magic-sdk/admin": "^1.4.0",
|
||||
"@next-auth/prisma-adapter": "^1.0.3",
|
||||
"@next-auth/prisma-adapter": "^1.0.4",
|
||||
"@prisma/client": "^3.12.0",
|
||||
"@webdeb/next-styles": "^1.1.1",
|
||||
"applicationinsights": "^2.2.0",
|
||||
@@ -86,4 +86,4 @@
|
||||
"prettier": "2.5.1",
|
||||
"prisma": "^3.12.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
-14
@@ -18,6 +18,7 @@ import { reduxForm, formValueSelector } from "redux-form";
|
||||
|
||||
import RegisterForm from "../../components/account/registerform";
|
||||
import { dehashString, hashAPIPath } from "../../actions";
|
||||
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, formData, loggedInUserEmail } = props;
|
||||
@@ -156,22 +157,23 @@ const Home = (props) => {
|
||||
};
|
||||
|
||||
export const getServerSideProps = wrapper.getServerSideProps(
|
||||
(store) =>
|
||||
async ({ query, req, res }) => {
|
||||
let hasRegistrationEmail = typeof query.id != "undefined";
|
||||
let loginEmailStr = "";
|
||||
(store) => async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
|
||||
if (hasRegistrationEmail == true) {
|
||||
loginEmailStr = dehashString(query.id);
|
||||
let thisSession = await getSession(ctx);
|
||||
|
||||
console.log(loginEmailStr);
|
||||
}
|
||||
return {
|
||||
props: {
|
||||
loggedInUserEmail: loginEmailStr,
|
||||
},
|
||||
};
|
||||
}
|
||||
console.log(
|
||||
"auth sess for register :",
|
||||
thisSession,
|
||||
thisSession.user.email
|
||||
);
|
||||
|
||||
return {
|
||||
props: {
|
||||
loggedInUserEmail: thisSession.user.email,
|
||||
},
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
const mapStateToProps = (state) => {
|
||||
|
||||
@@ -125,6 +125,12 @@ export default NextAuth({
|
||||
//signOut: "/auth/signout",
|
||||
error: "/auth/error", // Error code passed in query string as ?error=
|
||||
verifyRequest: "/auth/verify-request", // (used for check email message)
|
||||
// newUser: "/auth/new-user", // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||
newUser: "/account/register", // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||
},
|
||||
callbacks: {
|
||||
session: async (session, user) => {
|
||||
console.log(user);
|
||||
return Promise.resolve(session);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
deleteBlob,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import { deleteBlob } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
var blobName = req.query.blobname;
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
var checkquerypath =
|
||||
"/api/file/deleteblob?container=" +
|
||||
containerName.toLowerCase() +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
|
||||
console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await deleteBlob(containerName, "files/" + blobName).then((data) => {
|
||||
await deleteBlob(
|
||||
containerName,
|
||||
casefolderID + "/files/" + blobName
|
||||
).then((data) => {
|
||||
return res.status(200).json({ data: data });
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -1,24 +1,8 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
deleteBlob,
|
||||
downloadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
|
||||
import {
|
||||
DefaultAzureCredential,
|
||||
InteractiveBrowserCredential,
|
||||
EnvironmentCredential,
|
||||
ClientSecretCredential,
|
||||
} from "@azure/identity";
|
||||
import { downloadFile } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import CryptoJS from "crypto-js";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const WORDKEY = process.env.HASHKEY;
|
||||
|
||||
@@ -28,21 +12,27 @@ ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
var blobName = req.query.blobname;
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
var checkquerypath =
|
||||
"/api/file/downloadblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID +
|
||||
"&blobname=" +
|
||||
blobName;
|
||||
blobName.trim();
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const downloaded = await downloadFile(containerName, blobName);
|
||||
const downloaded = await downloadFile(
|
||||
containerName,
|
||||
casefolderID + "/files/" + decodeURI(blobName)
|
||||
);
|
||||
|
||||
res.setHeader(
|
||||
"content-disposition",
|
||||
"attachment; filename=" + blobName
|
||||
"attachment; filename=" + decodeURI(blobName)
|
||||
);
|
||||
return res.status(200).send(downloaded);
|
||||
} else {
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
import { getBlobs } from "../../../actions/azurestorage";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath = "/api/file/getbloblist?container=" + containerName;
|
||||
var checkquerypath =
|
||||
"/api/file/getbloblist?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID;
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await getBlobs(containerName).then((data) => {
|
||||
return res.status(200).json({ files: data });
|
||||
});
|
||||
} else {
|
||||
return res.status(400).json();
|
||||
}
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await getBlobs(containerName, casefolderID).then((data) => {
|
||||
return res.status(200).json({ files: data });
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
});
|
||||
|
||||
export const config = {
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
getProgressBlobs,
|
||||
downloadProgressFile,
|
||||
getProgressBlobs,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.container;
|
||||
var casefolderID = req.query.casefolderID;
|
||||
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath =
|
||||
"/api/file/getprogressobjblob?container=" + containerName;
|
||||
"/api/file/getprogressobjblob?container=" +
|
||||
containerName +
|
||||
"&casefolderID=" +
|
||||
casefolderID;
|
||||
|
||||
// console.log(hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
const blobObj = await getProgressBlobs(containerName)
|
||||
.then((data) => downloadProgressFile(containerName, data.path))
|
||||
const blobObj = await getProgressBlobs(containerName, casefolderID)
|
||||
.then((data) =>
|
||||
downloadProgressFile(containerName, data.path, casefolderID)
|
||||
)
|
||||
.then((data) => {
|
||||
return res.status(200).json(data);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
import {
|
||||
createContainer,
|
||||
getContainers,
|
||||
getBlobs,
|
||||
createBlob,
|
||||
uploadFile,
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions";
|
||||
|
||||
import middleware from "../middleware/middleware";
|
||||
import nextConnect from "next-connect";
|
||||
|
||||
const ApiProxy = nextConnect();
|
||||
ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.get(async (req, res) => {
|
||||
var containerName = req.query.ident;
|
||||
var checkHash = req.query.hash;
|
||||
var checkquerypath = "/api/file/setupcontainer?ident=" + containerName;
|
||||
|
||||
console.log(req.query);
|
||||
console.log(checkquerypath.length);
|
||||
console.log(hashAPIPath(checkquerypath));
|
||||
// console.log(checkquerypath, hashAPIPath(checkquerypath), checkHash);
|
||||
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
|
||||
|
||||
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
|
||||
await createContainer(containerName)
|
||||
.then((data) => {
|
||||
return res.status(200).json({ data: "success" });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(consoleLogger(err));
|
||||
res.status(400).json(err);
|
||||
});
|
||||
// } else {
|
||||
// return res.status(400).json();
|
||||
// }
|
||||
});
|
||||
|
||||
export const config = {
|
||||
api: {
|
||||
bodyParser: false,
|
||||
},
|
||||
};
|
||||
|
||||
export default ApiProxy;
|
||||
@@ -14,10 +14,15 @@ ApiProxy.use(middleware);
|
||||
|
||||
ApiProxy.post(async (req, res) => {
|
||||
var checkHash = req.query.hash;
|
||||
console.log(JSON.parse(req.body.appealData));
|
||||
console.log(req.files);
|
||||
// console.log(JSON.stringify(req.body));
|
||||
// console.log(JSON.stringify(req.body.appealData));
|
||||
// console.log(req.files);
|
||||
|
||||
const appealData = JSON.parse(req.body.appealData);
|
||||
const appealData = req.body.appealData;
|
||||
const containerID = req.body.containerID;
|
||||
const casefolderID = req.body.casefolderID;
|
||||
|
||||
console.log("there are files:", Object.keys(req.files).length);
|
||||
|
||||
// var checkquerypath = "/api/file/upload";
|
||||
|
||||
@@ -25,11 +30,18 @@ ApiProxy.post(async (req, res) => {
|
||||
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
||||
|
||||
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
||||
createContainer(appealData.pinswg_name.trim()).then((containerName) => {
|
||||
createBlob(appealData, containerName).then((data) => {
|
||||
uploadFile(req.files, containerName, data);
|
||||
});
|
||||
//createContainer(containerID).then((containerName) => {
|
||||
|
||||
console.log(
|
||||
"does this et folder name:",
|
||||
appealData.pinswg_name,
|
||||
casefolderID
|
||||
);
|
||||
createBlob(appealData, containerID, casefolderID).then((data) => {
|
||||
Object.keys(req.files).length > 0 &&
|
||||
uploadFile(req.files, containerID, casefolderID);
|
||||
});
|
||||
//});
|
||||
|
||||
return res.status(200).json({ data: "success" });
|
||||
// } else {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ function Error({ statusCode }, props) {
|
||||
<div>
|
||||
<Head>
|
||||
<title>
|
||||
{t("case:page-title")} - {t("common:service-name")}
|
||||
{t("common:error-page-title")} - {t("common:service-name")}
|
||||
</title>
|
||||
</Head>
|
||||
<div id="page_wrapper">
|
||||
|
||||
+20
-6
@@ -16,7 +16,10 @@ import Footer from "../components/footer";
|
||||
import Header from "../components/header";
|
||||
import Main from "../components/main";
|
||||
import ServiceBanner from "../components/servicebanner";
|
||||
import { setAccountDetails } from "../store/accountDetails/action";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
} from "../store/accountDetails/action";
|
||||
import { getGovGatewayConfig } from "../store/govgateway/action";
|
||||
import { wrapper } from "../store/store";
|
||||
import { getSession, useSession, signIn, signOut } from "next-auth/react";
|
||||
@@ -44,7 +47,13 @@ const Home = (props) => {
|
||||
expDate.setDate(now.getDate() + 1);
|
||||
|
||||
//console.log("hashed email str", loginEmailStr);
|
||||
hasLoginCode != false
|
||||
|
||||
//const { data: session } = useSession();
|
||||
|
||||
//console.log("has session:", session);
|
||||
//console.log("has LoginCode", hasLoginCode);
|
||||
|
||||
hasLoginCode == false
|
||||
? console.log("no session")
|
||||
: _.has(loggedInUserId, "value")
|
||||
? _.isEmpty(loggedInUserId.value)
|
||||
@@ -166,18 +175,20 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
var relayToken = await getToken();
|
||||
relayToken = relayToken.access_token;
|
||||
|
||||
console.log("auth sess:", thisSession);
|
||||
console.log("\n///////////////\nauth sess:", thisSession);
|
||||
|
||||
const showLoginCheck = process.env.SHOWLOGIN || false;
|
||||
const showMapCheck = process.env.SHOWMAPS || false;
|
||||
|
||||
const hasLoginCode = thisSession != null;
|
||||
let hasLoginCode = thisSession != null;
|
||||
|
||||
console.log("server side has session:", thisSession != null);
|
||||
|
||||
// let providerConfig = await getProviderConfig();
|
||||
let ggLocale =
|
||||
typeof query.ui_locales != "undefined" && query.ui_locales;
|
||||
|
||||
console.log("\n", "hasloginCode:", hasLoginCode);
|
||||
console.log("hasloginCode:", hasLoginCode);
|
||||
|
||||
// store.dispatch(getGovGatewayConfig(providerConfig));
|
||||
|
||||
@@ -188,6 +199,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
if (hasLoginCode == true) {
|
||||
loginEmailStr = hashString(thisSession.user.email);
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
portalUserObj = await getPortalLogin(
|
||||
thisSession.user.email,
|
||||
relayToken
|
||||
@@ -210,7 +223,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
} else {
|
||||
console.log("empty session");
|
||||
}
|
||||
|
||||
console.log("///////////////\n");
|
||||
if (ggToken.status == 400) {
|
||||
return {
|
||||
redirect: {
|
||||
@@ -227,6 +240,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
hasSession: hasLoginCode,
|
||||
loggedInUserId: portalUserObj,
|
||||
loggedInUserEmail: loginEmailStr,
|
||||
hasLoginCode: hasLoginCode,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getPickLists,
|
||||
getPartSavedAppeal,
|
||||
getFilesFromBlob,
|
||||
getProgressFromBlob,
|
||||
} from "../../actions";
|
||||
import { getProviderConfig } from "../../actions/govgateway";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
@@ -23,7 +24,10 @@ import BuildSection from "../../components/newappeal/buildsection";
|
||||
import CompleteAppeal from "../../components/newappeal/complete";
|
||||
import TimeOut from "../../components/timeout";
|
||||
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
setLoggedInUserId,
|
||||
setContainerID,
|
||||
} from "../../store/accountDetails/action";
|
||||
import {
|
||||
setAppealLPA,
|
||||
setAppealType,
|
||||
@@ -36,6 +40,8 @@ import { setForm } from "../../store/formData/action";
|
||||
import { getGovGatewayConfig } from "../../store/govgateway/action";
|
||||
import { wrapper } from "../../store/store";
|
||||
import { getPartSavedDetails } from "../../components/utils";
|
||||
import { getProgressBlobs } from "../../actions/azurestorage";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
|
||||
let Home = (props) => {
|
||||
const { footerLinks, pages, formData } = props;
|
||||
@@ -62,7 +68,7 @@ let Home = (props) => {
|
||||
|
||||
var tabs = xpath.select("//form/tabs/tab[*]", doc);
|
||||
|
||||
let optionsStr = props.appealType.appealTypeOptions.value;
|
||||
let optionsStr = props.appealType.appealTypeOptions.value || {};
|
||||
|
||||
// let selectedObj = jsonpath.query(optionsStr, "$..value");
|
||||
|
||||
@@ -215,38 +221,57 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
console.log("the query", query.appealtypes);
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
|
||||
const [appealTypeData, mandatoryFieldsData, pickListData, blobList] =
|
||||
await Promise.all([
|
||||
await getAppealsTypes(),
|
||||
await getMandatoryFields(query.appealtypes),
|
||||
await getPickLists(query.appealtypes),
|
||||
await getFilesFromBlob(query.casereference),
|
||||
]);
|
||||
let thisSession = await getSession(ctx);
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
let searchResultsObj = await getPartSavedAppeal(query.casereference);
|
||||
//console.log("eeee:", searchResultsObj);
|
||||
let searchDetailsObj = await getPartSavedDetails(searchResultsObj);
|
||||
let loggedInUserIdent = thisSession.user.id;
|
||||
|
||||
searchDetailsObj = searchDetailsObj[0].value[0];
|
||||
console.log("logged ident:", loggedInUserIdent);
|
||||
|
||||
Object.keys(searchDetailsObj).forEach((key) => {
|
||||
if (searchDetailsObj[key] === null) {
|
||||
delete searchDetailsObj[key];
|
||||
}
|
||||
});
|
||||
const [
|
||||
appealTypeData,
|
||||
mandatoryFieldsData,
|
||||
pickListData,
|
||||
blobList,
|
||||
blobProgress,
|
||||
] = await Promise.all([
|
||||
await getAppealsTypes(),
|
||||
await getMandatoryFields(query.appealtypes),
|
||||
await getPickLists(query.appealtypes),
|
||||
await getFilesFromBlob(loggedInUserIdent, query.casereference),
|
||||
await getProgressFromBlob(loggedInUserIdent, query.casereference),
|
||||
]);
|
||||
|
||||
console.log("has blobprogess:", loggedInUserIdent, query.casereference);
|
||||
|
||||
//
|
||||
// Removed to make progress from Blob not CRM
|
||||
//
|
||||
|
||||
// let searchResultsObj = await getPartSavedAppeal(query.casereference);
|
||||
// //console.log("eeee:", searchResultsObj);
|
||||
// let searchDetailsObj = await getPartSavedDetails(searchResultsObj);
|
||||
|
||||
// searchDetailsObj = searchDetailsObj[0].value[0];
|
||||
|
||||
// Object.keys(searchDetailsObj).forEach((key) => {
|
||||
// if (searchDetailsObj[key] === null) {
|
||||
// delete searchDetailsObj[key];
|
||||
// }
|
||||
// });
|
||||
|
||||
//console.log("appeal:", searchDetailsObj);
|
||||
|
||||
searchDetailsObj = JSON.stringify(searchDetailsObj);
|
||||
searchDetailsObj = searchDetailsObj.replace(/:true/gm, `:"Yes"`);
|
||||
searchDetailsObj = searchDetailsObj.replace(/:false/gm, `:"No"`);
|
||||
searchDetailsObj = JSON.parse(searchDetailsObj);
|
||||
// searchDetailsObj = JSON.stringify(searchDetailsObj);
|
||||
// searchDetailsObj = searchDetailsObj.replace(/:true/gm, `:"Yes"`);
|
||||
// searchDetailsObj = searchDetailsObj.replace(/:false/gm, `:"No"`);
|
||||
// searchDetailsObj = JSON.parse(searchDetailsObj);
|
||||
|
||||
let caseReference = {};
|
||||
|
||||
caseReference.ticketnumber = query.casereference;
|
||||
caseReference.incidentid = query.inid;
|
||||
caseReference.caseDetails = searchDetailsObj;
|
||||
caseReference.caseDetails = blobProgress; //searchDetailsObj;
|
||||
|
||||
var path = require("path");
|
||||
const configDirectory = path.resolve(process.cwd(), "data/formsxml");
|
||||
@@ -269,6 +294,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
||||
store.dispatch(setAppealType(appealTypeData));
|
||||
store.dispatch(setFilesForAppeal(blobList));
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
+19
-1
@@ -12,6 +12,7 @@ import {
|
||||
getPortalModuleDetails,
|
||||
getWatchedCases,
|
||||
} from "../../actions";
|
||||
import { createContainer } from "../../actions/azurestorage";
|
||||
import { getProviderConfig } from "../../actions/govgateway";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
import CookieBanner from "../../components/cookieBanner";
|
||||
@@ -21,6 +22,7 @@ import MyPortal from "../../components/myportal";
|
||||
import { getFormCollectionByID } from "../../components/utils";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
import {
|
||||
@@ -161,6 +163,18 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
if (_.has(thisSession, "user") == false) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/error",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
//Create Storage container for logged in user
|
||||
await createContainer(thisSession.user.id);
|
||||
|
||||
let providerConfig = await getProviderConfig();
|
||||
|
||||
store.dispatch(getGovGatewayConfig(providerConfig));
|
||||
@@ -213,9 +227,13 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(
|
||||
setAwaitingSubmissionDetails(awaitingSubmissionDetails)
|
||||
);
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
return {
|
||||
props: { showFileUpload: process.env.SHOWFILEUPLOAD },
|
||||
props: {
|
||||
showFileUpload: process.env.SHOWFILEUPLOAD,
|
||||
containerID: thisSession.user.id,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import { useEffect } from "react";
|
||||
import { connect } from "react-redux";
|
||||
import xpath from "xpath";
|
||||
import {
|
||||
createCase,
|
||||
getCase,
|
||||
getAppealsTypes,
|
||||
getMandatoryFields,
|
||||
getPickLists,
|
||||
getFilesFromBlob,
|
||||
getProgressFromBlob,
|
||||
} from "../../actions";
|
||||
import { getProviderConfig } from "../../actions/govgateway";
|
||||
import Breadcrumbs from "../../components/breadcrumbs";
|
||||
@@ -24,7 +24,10 @@ import BuildSection from "../../components/newappeal/buildsection";
|
||||
import CompleteAppeal from "../../components/newappeal/complete";
|
||||
import TimeOut from "../../components/timeout";
|
||||
|
||||
import { setLoggedInUserId } from "../../store/accountDetails/action";
|
||||
import {
|
||||
setLoggedInUserId,
|
||||
setContainerID,
|
||||
} from "../../store/accountDetails/action";
|
||||
import {
|
||||
setAppealLPA,
|
||||
setAppealType,
|
||||
@@ -36,6 +39,8 @@ import {
|
||||
import { setForm } from "../../store/formData/action";
|
||||
import { getGovGatewayConfig } from "../../store/govgateway/action";
|
||||
import { wrapper } from "../../store/store";
|
||||
import { getProgressBlobs } from "../../actions/azurestorage";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
|
||||
let Home = (props) => {
|
||||
const { footerLinks, pages, formData } = props;
|
||||
@@ -217,17 +222,27 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
console.log("ref:", query.id);
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
|
||||
let thisSession = await getSession(ctx);
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
let loggedInUserIdent = thisSession.user.id;
|
||||
|
||||
console.log("logged ident:", loggedInUserIdent);
|
||||
|
||||
const [
|
||||
caseReferenceData,
|
||||
appealTypeData,
|
||||
mandatoryFieldsData,
|
||||
pickListData,
|
||||
//blobList,
|
||||
blobProgress,
|
||||
] = await Promise.all([
|
||||
await getCase(query.id),
|
||||
await getAppealsTypes(),
|
||||
await getMandatoryFields(query.appealtypes),
|
||||
await getPickLists(query.appealtypes),
|
||||
await getProgressFromBlob(loggedInUserIdent, query.casereference),
|
||||
|
||||
//await getFilesFromBlob(query.casereference),
|
||||
]);
|
||||
|
||||
@@ -255,6 +270,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setCaseReference(caseReference));
|
||||
store.dispatch(setForm(xmlStr, mandatoryFieldsData, pickListData));
|
||||
store.dispatch(setAppealType(appealTypeData));
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
//store.dispatch(setFilesForAppeal(blobList));
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import useTranslation from "next-translate/useTranslation";
|
||||
import Head from "next/head";
|
||||
import { getSession, useSession } from "next-auth/react";
|
||||
import _ from "lodash";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import { connect } from "react-redux";
|
||||
import {
|
||||
@@ -14,6 +17,7 @@ import Header from "../../components/header";
|
||||
import CreateCase from "../../components/newappeal/createCase";
|
||||
import {
|
||||
setAccountDetails,
|
||||
setContainerID,
|
||||
setLoggedInUserId,
|
||||
} from "../../store/accountDetails/action";
|
||||
import { setAppealType } from "../../store/appealType/action";
|
||||
@@ -24,7 +28,7 @@ import { getGovGatewayConfig } from "../../store/govgateway/action";
|
||||
import { getProviderConfig } from "../../actions/govgateway";
|
||||
|
||||
const Home = (props) => {
|
||||
const { footerLinks, pages, formData } = props;
|
||||
const { footerLinks, pages, formData, loggedInUserIdent } = props;
|
||||
let { t, lang } = useTranslation();
|
||||
|
||||
const router = useRouter();
|
||||
@@ -118,6 +122,7 @@ const Home = (props) => {
|
||||
appealType={props.setAppealType}
|
||||
loggedInUser={props.accountDetails.loggedinUserId}
|
||||
whichForm={props.form}
|
||||
containerID={props.accountDetails.containerID}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
@@ -135,7 +140,18 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
const { cookies } = req;
|
||||
|
||||
console.log("/newappeal - cookies ", cookies);
|
||||
let thisSession = await getSession(ctx);
|
||||
console.log("nextAuth Session:", thisSession);
|
||||
|
||||
if (_.has(thisSession, "user") == false) {
|
||||
return {
|
||||
redirect: {
|
||||
destination: "/error",
|
||||
permanent: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
let loggedInUserIdent = thisSession.user.id;
|
||||
let loggedInUser = cookies.pinsUser;
|
||||
|
||||
console.log("has loggedInUser", loggedInUser);
|
||||
@@ -157,6 +173,11 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
||||
store.dispatch(setLPA(lpaData));
|
||||
store.dispatch(setLoggedInUserId(loggedInUser));
|
||||
store.dispatch(setAccountDetails(accountDetails));
|
||||
store.dispatch(setContainerID(thisSession.user.id));
|
||||
|
||||
return {
|
||||
props: { loggedInUserIdent: loggedInUserIdent },
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -1,57 +1,61 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `accounts` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`user_id` VARCHAR(191) NOT NULL,
|
||||
`type` VARCHAR(191) NOT NULL,
|
||||
`provider` VARCHAR(191) NOT NULL,
|
||||
`provider_account_id` VARCHAR(191) NOT NULL,
|
||||
`refresh_token` TEXT NULL,
|
||||
`access_token` TEXT NULL,
|
||||
`expires_at` INTEGER NULL,
|
||||
`token_type` VARCHAR(191) NULL,
|
||||
`scope` VARCHAR(191) NULL,
|
||||
`id_token` TEXT NULL,
|
||||
`session_state` VARCHAR(191) NULL,
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
CREATE TABLE accounts (
|
||||
id VARCHAR(191) NOT NULL,
|
||||
user_id VARCHAR(191) NOT NULL,
|
||||
type VARCHAR(191) NOT NULL,
|
||||
provider VARCHAR(191) NOT NULL,
|
||||
provider_account_id VARCHAR(191) NOT NULL,
|
||||
refresh_token VARCHAR(max) NULL,
|
||||
access_token VARCHAR(max) NULL,
|
||||
expires_at INTEGER NULL,
|
||||
token_type VARCHAR(191) NULL,
|
||||
scope VARCHAR(191) NULL,
|
||||
id_token VARCHAR(max) NULL,
|
||||
session_state VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `accounts_provider_provider_account_id_key`(`provider`, `provider_account_id`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
CONSTRAINT accounts_provider_provider_account_id_key UNIQUE (provider, provider_account_id),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `sessions` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`session_token` VARCHAR(191) NOT NULL,
|
||||
`user_id` VARCHAR(191) NOT NULL,
|
||||
`expires` DATETIME(3) NOT NULL,
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
CREATE TABLE sessions (
|
||||
id VARCHAR(191) NOT NULL,
|
||||
session_token VARCHAR(191) NOT NULL,
|
||||
user_id VARCHAR(191) NOT NULL,
|
||||
expires DATETIME2(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `sessions_session_token_key`(`session_token`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
CONSTRAINT sessions_session_token_key UNIQUE (session_token),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `users` (
|
||||
`id` VARCHAR(191) NOT NULL,
|
||||
`name` VARCHAR(191) NULL,
|
||||
`email` VARCHAR(191) NULL,
|
||||
`email_verified` DATETIME(3) NULL,
|
||||
`image` VARCHAR(191) NULL,
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
CREATE TABLE users (
|
||||
id VARCHAR(191) NOT NULL,
|
||||
name VARCHAR(191) NULL,
|
||||
email VARCHAR(191) NULL,
|
||||
email_verified DATETIME2(3) NULL,
|
||||
image VARCHAR(191) NULL,
|
||||
|
||||
UNIQUE INDEX `users_email_key`(`email`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
CONSTRAINT users_email_key UNIQUE (email),
|
||||
PRIMARY KEY (id)
|
||||
)
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE `verificationtokens` (
|
||||
`identifier` VARCHAR(191) NOT NULL,
|
||||
`token` VARCHAR(191) NOT NULL,
|
||||
`expires` DATETIME(3) NOT NULL,
|
||||
-- SQLINES LICENSE FOR EVALUATION USE ONLY
|
||||
CREATE TABLE verificationtokens (
|
||||
identifier VARCHAR(191) NOT NULL,
|
||||
token VARCHAR(191) NOT NULL,
|
||||
expires DATETIME2(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `verificationtokens_token_key`(`token`),
|
||||
UNIQUE INDEX `verificationtokens_identifier_token_key`(`identifier`, `token`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
CONSTRAINT verificationtokens_token_key UNIQUE (token),
|
||||
CONSTRAINT verificationtokens_identifier_token_key UNIQUE (identifier, token)
|
||||
)
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `accounts` ADD CONSTRAINT `accounts_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE accounts ADD CONSTRAINT accounts_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
ALTER TABLE sessions ADD CONSTRAINT sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String @map("provider_account_id")
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([provider, providerAccountId])
|
||||
@@map("accounts")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId String @map("user_id")
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
email String? @unique
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
image String?
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verificationtokens")
|
||||
}
|
||||
+16
-17
@@ -1,27 +1,26 @@
|
||||
datasource db {
|
||||
provider = "mysql"
|
||||
url = env("DATABASE_URL")
|
||||
provider = "sqlserver"
|
||||
url = env("DATABASE_URL")
|
||||
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
|
||||
}
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
|
||||
|
||||
model Account {
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String @map("provider_account_id")
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
id String @id @default(cuid())
|
||||
userId String @map("user_id")
|
||||
type String
|
||||
provider String
|
||||
providerAccountId String
|
||||
refresh_token String? @db.Text
|
||||
access_token String? @db.Text
|
||||
expires_at Int?
|
||||
token_type String?
|
||||
scope String?
|
||||
id_token String? @db.Text
|
||||
session_state String?
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ export const AccountDetailsDataActionTypes = {
|
||||
SETLOGGEDINUSER: "SETLOGGEDINUSER",
|
||||
SETACCOUNTCREATED: "SETACCOUNTCREATED",
|
||||
USER_LOGOUT: "USER_LOGOUT",
|
||||
SETCONTAINERID: "SETCONTAINERID",
|
||||
};
|
||||
|
||||
export const setCookieConsent = (cookieObj) => (dispatch) => {
|
||||
@@ -47,3 +48,10 @@ export const setAccCr = (accCr) => (dispatch) => {
|
||||
accCr: accCr,
|
||||
});
|
||||
};
|
||||
|
||||
export const setContainerID = (containerID) => (dispatch) => {
|
||||
return dispatch({
|
||||
type: AccountDetailsDataActionTypes.SETCONTAINERID,
|
||||
containerID: containerID,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ const AccountDetailsDataInitialState = {
|
||||
loggedinUserId: "",
|
||||
accCr: false,
|
||||
cookieObj: "",
|
||||
containerID: "",
|
||||
};
|
||||
|
||||
export default function reducer(
|
||||
@@ -32,6 +33,11 @@ export default function reducer(
|
||||
...state,
|
||||
cookieObj: action.cookieObj,
|
||||
};
|
||||
case AccountDetailsDataActionTypes.SETCONTAINERID:
|
||||
return {
|
||||
...state,
|
||||
containerID: action.containerID,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user