Fix authenticated requests on Native

This commit is contained in:
Reckless_Satoshi 2023-03-04 02:14:45 -08:00
parent 2e71ffb3de
commit cee6ffbf45
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -10,20 +10,16 @@ class ApiNativeClient implements ApiClient {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}; };
const robotToken = systemClient.getItem('robot_token'); const sessionid = systemClient.getCookie('sessionid');
if (robotToken) { const csrftoken = systemClient.getCookie('csrftoken');
const sessionid = systemClient.getCookie('sessionid');
const csrftoken = systemClient.getCookie('csrftoken');
const pubKey = systemClient.getItem('pub_key');
headers = { headers = {
...headers, ...headers,
...{ ...{
'X-CSRFToken': csrftoken, 'X-CSRFToken': csrftoken,
Cookie: `sessionid=${sessionid};robot_token=${robotToken};csrftoken=${csrftoken};pub_key=${pubKey}`, Cookie: `sessionid=${sessionid};token=${csrftoken}`,
}, },
}; };
}
return headers; return headers;
}; };