Skip to content

Commit

Permalink
Use axios to correctly encode credentials (#9)
Browse files Browse the repository at this point in the history
* do basic auth correct

* keys match vars

* 1.0.1
  • Loading branch information
freddieptf authored Jan 17, 2024
1 parent 9e4f3e5 commit 2037167
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cht-user-management",
"version": "1.0.0",
"version": "1.0.1",
"main": "dist/index.js",
"dependencies": {
"@fastify/autoload": "^5.8.0",
Expand Down
7 changes: 6 additions & 1 deletion src/lib/cht-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ export class ChtApi {
public static async createSession(authInfo: AuthenticationInfo, username : string, password: string): Promise<ChtSession> {
const COUCH_AUTH_COOKIE_NAME = 'AuthSession=';
const protocol = authInfo.useHttp ? 'http' : 'https';
const sessionUrl = `${protocol}://${username}:${password}@${authInfo.domain}/_session`;
const sessionUrl = `${protocol}://${authInfo.domain}/_session`;
const resp = await axios.post(sessionUrl, {
name: username,
password,
}, {
auth: {
username,
password
}
});
const setCookieHeader = (resp.headers as AxiosHeaders).get('set-cookie') as AxiosHeaders;
const sessionToken = setCookieHeader?.[0].split(';')
Expand Down

0 comments on commit 2037167

Please sign in to comment.