Skip to content

Commit

Permalink
Fix form data stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ckcr4lyf committed May 26, 2023
1 parent 5e8aadb commit a9c9313
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions __tests__/qbittorrent/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ test('loginV2', async t => {
password: 'adminadmin'
}

const scope = nock(fakeSettings.url).post('/api/v2/auth/login', (b) => {
console.log(b);
return true;
const scope = nock(fakeSettings.url).post('/api/v2/auth/login', {
username: 'admin',
password: 'adminadmin'
}).reply(200, {}, {
'set-cookie': 'SID=1234'
});
Expand Down
9 changes: 8 additions & 1 deletion build/src/qbittorrent/api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions src/qbittorrent/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,14 @@ enum ApiEndpoints {
}

export const login = (qbittorrentSettings: QBITTORRENT_SETTINGS): Promise<AxiosResponse> => {
const form = new FormData();
form.append('username', qbittorrentSettings.username);
form.append('password', qbittorrentSettings.password);
return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, form);
return axios.post(`${qbittorrentSettings.url}${ApiEndpoints.login}`, {
username: qbittorrentSettings.username,
password: qbittorrentSettings.password
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
}
});
}

// We just need the hash for some of the API calls
Expand Down

0 comments on commit a9c9313

Please sign in to comment.