Skip to content

Commit

Permalink
do basic auth correct
Browse files Browse the repository at this point in the history
  • Loading branch information
freddieptf committed Jan 17, 2024
1 parent 4bbb7cf commit d73c0ad
Showing 1 changed file with 6 additions and 1 deletion.
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:username,
password: password
}
});
const setCookieHeader = (resp.headers as AxiosHeaders).get('set-cookie') as AxiosHeaders;
const sessionToken = setCookieHeader?.[0].split(';')
Expand Down

0 comments on commit d73c0ad

Please sign in to comment.