Skip to content

Commit ed27578

Browse files
author
Steven Surowiec
committed
Merge pull request #44 from Woellchen/use_header_auth
replaced uri auth with header auth
2 parents 77dcb66 + b43f650 commit ed27578

File tree

2 files changed

+92
-26
lines changed

2 files changed

+92
-26
lines changed

lib/jira.js

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,20 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
158158
var uri = url.format({
159159
protocol: this.protocol,
160160
hostname: this.host,
161-
auth: this.username + ':' + this.password,
162161
port: this.port,
163162
pathname: basePath + apiVersion + pathname
164163
});
165164
return decodeURIComponent(uri);
166165
};
167166

167+
this.doRequest = function(options, callback) {
168+
options.auth = {
169+
'user': this.username,
170+
'pass': this.password
171+
};
172+
173+
this.request(options, callback);
174+
};
168175

169176
};
170177

@@ -189,7 +196,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
189196
method: 'GET'
190197
};
191198

192-
this.request(options, function(error, response, body) {
199+
this.doRequest(options, function(error, response, body) {
193200

194201
if (error) {
195202
callback(error, null);
@@ -234,7 +241,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
234241
method: 'GET'
235242
};
236243

237-
this.request(options, function(error, response, body) {
244+
this.doRequest(options, function(error, response, body) {
238245

239246
if (error) {
240247
callback(error, null);
@@ -277,7 +284,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
277284
method: 'GET'
278285
};
279286

280-
this.request(options, function(error, response, body) {
287+
this.doRequest(options, function(error, response, body) {
281288

282289
if (error) {
283290
callback(error, null);
@@ -325,7 +332,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
325332
json: true
326333
};
327334

328-
this.request(options, function(error, response) {
335+
this.doRequest(options, function(error, response) {
329336

330337
if (error) {
331338
callback(error, null);
@@ -380,7 +387,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
380387
json:true
381388
};
382389

383-
this.request(options, function(error, response) {
390+
this.doRequest(options, function(error, response) {
384391

385392
if (error) {
386393
callback(error, null);
@@ -433,7 +440,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
433440
json: true
434441
};
435442

436-
this.request(options, function(error, response) {
443+
this.doRequest(options, function(error, response) {
437444

438445
if (error) {
439446
callback(error, null);
@@ -495,7 +502,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
495502

496503
logger.log(options.uri);
497504

498-
this.request(options, function(error, response) {
505+
this.doRequest(options, function(error, response) {
499506

500507
if (error) {
501508
callback(error, null);
@@ -556,7 +563,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
556563
body: link
557564
};
558565

559-
this.request(options, function(error, response) {
566+
this.doRequest(options, function(error, response) {
560567

561568
if (error) {
562569
callback(error, null);
@@ -597,7 +604,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
597604
method: 'GET'
598605
};
599606

600-
this.request(options, function(error, response, body) {
607+
this.doRequest(options, function(error, response, body) {
601608

602609
if (error) {
603610
callback(error, null);
@@ -653,7 +660,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
653660
json: true,
654661
body: version
655662
};
656-
this.request(options, function(error, response, body) {
663+
this.doRequest(options, function(error, response, body) {
657664

658665
if (error) {
659666
callback(error, null);
@@ -722,7 +729,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
722729
}
723730
};
724731

725-
this.request(options, function(error, response, body) {
732+
this.doRequest(options, function(error, response, body) {
726733

727734
if (error) {
728735
callback(error, null);
@@ -780,7 +787,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
780787
followAllRedirects: true
781788
};
782789

783-
this.request(options, function(error, response, body) {
790+
this.doRequest(options, function(error, response, body) {
784791

785792
if (error) {
786793
callback(error, null);
@@ -844,7 +851,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
844851
body: issue
845852
};
846853

847-
this.request(options, function(error, response, body) {
854+
this.doRequest(options, function(error, response, body) {
848855

849856
if (error) {
850857
callback(error, null);
@@ -885,7 +892,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
885892
json: true
886893
};
887894

888-
this.request(options, function(error, response) {
895+
this.doRequest(options, function(error, response) {
889896

890897
if (error) {
891898
callback(error, null);
@@ -923,7 +930,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
923930
json: true
924931
};
925932

926-
this.request(options, function(error, response) {
933+
this.doRequest(options, function(error, response) {
927934

928935
if (error) {
929936
callback(error, null);
@@ -982,7 +989,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
982989
json: true
983990
};
984991

985-
this.request(options, function(error, response, body) {
992+
this.doRequest(options, function(error, response, body) {
986993

987994
if (error) {
988995
callback(error, null);
@@ -1035,7 +1042,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
10351042
json: true
10361043
};
10371044

1038-
this.request(options, function(error, response, body) {
1045+
this.doRequest(options, function(error, response, body) {
10391046

10401047
if (error) {
10411048
callback(error, null);
@@ -1083,7 +1090,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
10831090
json: true
10841091
};
10851092

1086-
this.request(options, function(error, response, body) {
1093+
this.doRequest(options, function(error, response, body) {
10871094

10881095
if (error) {
10891096
callback(error, null);
@@ -1160,7 +1167,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
11601167
json: true
11611168
};
11621169

1163-
this.request(options, function(error, response, body) {
1170+
this.doRequest(options, function(error, response, body) {
11641171

11651172
if (error) {
11661173
callback(error, null);
@@ -1202,7 +1209,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
12021209
json: true
12031210
};
12041211

1205-
this.request(options, function(error, response) {
1212+
this.doRequest(options, function(error, response) {
12061213

12071214
if (error) {
12081215
callback(error, null);
@@ -1250,7 +1257,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
12501257
json: true
12511258
};
12521259

1253-
this.request(options, function(error, response, body) {
1260+
this.doRequest(options, function(error, response, body) {
12541261

12551262
if (error) {
12561263
callback(error, null);
@@ -1293,7 +1300,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
12931300
json: true
12941301
};
12951302

1296-
this.request(options, function(error, response, body) {
1303+
this.doRequest(options, function(error, response, body) {
12971304
if (error) {
12981305
callback(error, null);
12991306
return;
@@ -1358,7 +1365,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
13581365
json: true
13591366
};
13601367

1361-
this.request(options, function(error, response, body) {
1368+
this.doRequest(options, function(error, response, body) {
13621369

13631370
if (error) {
13641371
callback(error, null);
@@ -1411,7 +1418,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
14111418
json: true
14121419
};
14131420

1414-
this.request(options, function(error, response, body) {
1421+
this.doRequest(options, function(error, response, body) {
14151422

14161423
if (error) {
14171424
callback(error, null);

0 commit comments

Comments
 (0)