Skip to content

Commit b5cdaaa

Browse files
authored
Merge pull request #284 from parthlambdatest/Dot-4961
rectify the way we auth
2 parents 35342da + 987818d commit b5cdaaa

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/lib/httpClient.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ export default class httpClient {
4646
this.axiosInstance = axios.create(axiosConfig);
4747

4848
this.axiosInstance.interceptors.request.use((config) => {
49-
if (!config.headers['projectToken']) {
49+
if (!config.headers['projectToken'] && this.projectToken !== '') {
5050
config.headers['projectToken'] = this.projectToken;
51-
}
52-
config.headers['projectName'] = this.projectName;
53-
if (!config.headers['username'] || config.headers['username'] === '') {
54-
config.headers['username'] = this.username;
55-
}
56-
if (!config.headers['accessKey'] || config.headers['accessKey'] === '') {
57-
config.headers['accessKey'] = this.accessKey;
51+
} else if ((!config.headers['projectName'] && this.projectName !== '')) {
52+
config.headers['projectName'] = this.projectName;
53+
if (!config.headers['username'] || config.headers['username'] === '') {
54+
config.headers['username'] = this.username;
55+
}
56+
if (!config.headers['accessKey'] || config.headers['accessKey'] === '') {
57+
config.headers['accessKey'] = this.accessKey;
58+
}
5859
}
5960
return config;
6061
});
@@ -158,10 +159,15 @@ export default class httpClient {
158159
let authResult = 1;
159160
let userName = '';
160161
let passWord = '';
161-
if (ctx.config.tunnel && ctx.config.tunnel?.user && ctx.config.tunnel?.key) {
162-
userName = ctx.config.tunnel.user
163-
passWord = ctx.config.tunnel.key
164-
}
162+
if (ctx.config.tunnel) {
163+
if (ctx.config.tunnel?.user && ctx.config.tunnel?.key) {
164+
userName = ctx.config.tunnel.user
165+
passWord = ctx.config.tunnel.key
166+
} else {
167+
userName = this.username
168+
passWord = this.accessKey
169+
}
170+
}
165171
if (this.projectToken) {
166172
authResult = 0;
167173
}

0 commit comments

Comments
 (0)