Fixed because we SSO bois now

master
dabbott 2 years ago
parent 8423834b4e
commit 64e533d6b9

@ -1,6 +1,32 @@
fetch = require("node-fetch")
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
// process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
cookie = "cookie!"
oncArr = [
{
year:2022,
month: 01,
day: 01
},
{
year:2022,
month: 01,
day: 14
},
{
year:2022,
month: 02,
day: 04
},
{
year:2022,
month: 02,
day: 25
}
]
function makeArr(startDateObj,username, password){
date = new Date(startDateObj.year+"-"+startDateObj.month+"-"+startDateObj.day)
@ -52,37 +78,39 @@ function makeArr(startDateObj,username, password){
dateMs = dateMs+86400000
i =i-1
}
dateSend(username, password, dateArr)
dateSend(dateArr, cookie)
}
async function dateSend(username, password, dateArr) {
const loginRes = await fetch('https://timesheets.node4.co.uk/api/login', {
method: 'post',
body: JSON.stringify({"email":username+"@node4.co.uk","password":password}),
headers: {'Content-Type': 'application/json'}
})
const loginData = await loginRes.json();
async function dateSend(dateArr, cookie) {
fetch('https://timesheets.node4.co.uk/api/on-call', {
method: 'post',
body: JSON.stringify(dateArr),
headers: {
'Content-Type': 'application/json',
"authorization": "Bearer "+loginData.payload.token
}
})
"Accept":"application/json, text/plain, */*",
"Accept-Encoding":"gzip, deflate, br",
"Accept-Language":"en-US,en;q=0.5",
"Cache-Control":"no-cache",
"Connection":"keep-alive",
"Content-Type":"application/json",
"Cookie": cookie,
"Host": "timesheets.node4.co.uk",
"Pragma":"no-cache",
"Referer":"https://timesheets.node4.co.uk/on-call/entries",
"Sec-Fetch-Dest":"empty",
"Sec-Fetch-Mode":"cors",
"Sec-Fetch-Site":"same-origin",
"Sec-GPC":1,
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0"
}
})
.then(res => res.text())
.then(body => console.log(body));
}
//main()
console.log()
obj = {
year:2021,
month: 02,
day: 12
}
oncArr.forEach(obj => {
makeArr(obj)
})
makeArr(obj, "d.abbott","pass")
Loading…
Cancel
Save