-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoint to allow pulling log files from the web_interface #24
base: master
Are you sure you want to change the base?
Conversation
var authHeader = req.get("Authorization") | ||
var authToken | ||
if (authHeader) { | ||
if (authHeader.indexOf(" ") == -1) { | ||
authToken = authHeader | ||
} else { | ||
authHeader = authHeader.split(" ") | ||
authToken = authHeader[1] | ||
} | ||
} else { | ||
res.set("Authorization", "Basic base64_auth_token") | ||
return res | ||
.type("txt") | ||
.status(401) | ||
.send( | ||
'Access denied: invalid Authorization Header format. Correct format: "Authorization: Basic base64_auth_token"' | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutely sure that this part can be carried out from each route, avoiding terrible code repetition!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is true. We will add that to the list of things to address.
try { | ||
var logAndOutputFiles = [] | ||
const tarFile = 'LogAndOutputFiles.tar' | ||
const userAttachments = process.cwd() + "/attachments" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work at Windows OS. You should use path
object to join paths.
@@ -1113,4 +1209,14 @@ function isJson(str) { | |||
return str | |||
} | |||
|
|||
function checkForLog(fileName, pathName, destDir, list) { | |||
if (!fs.existsSync(pathName)) { | |||
console.log('get logs: cannot find:' + pathName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is much better to use return
after this line and avoid using else
.
No description provided.