Skip to content

Commit 4bf574c

Browse files
committed
feat: Add sudo abilities #203
1 parent f2cc73b commit 4bf574c

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/infrastructure/BaseService.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ interface BaseModelOptions {
88
oauthToken?: string;
99
useXMLHttpRequest?: boolean;
1010
version?: string;
11+
sudo?: boolean;
1112
rejectUnauthorized?: boolean;
1213
}
1314

@@ -23,6 +24,7 @@ class BaseModel {
2324
constructor({
2425
token,
2526
oauthToken,
27+
sudo,
2628
url = 'https://gitlab.com',
2729
useXMLHttpRequest = false,
2830
version = 'v4',
@@ -34,11 +36,12 @@ class BaseModel {
3436
this.useXMLHttpRequest = useXMLHttpRequest;
3537
this.rejectUnauthorized = rejectUnauthorized;
3638

37-
if (oauthToken) {
38-
this.headers.authorization = `Bearer ${oauthToken}`;
39-
} else if (token) {
40-
this.headers['private-token'] = token;
41-
}
39+
// Handle auth tokens
40+
if (oauthToken) this.headers.authorization = `Bearer ${oauthToken}`;
41+
else if (token) this.headers['private-token'] = token;
42+
43+
// Set sudo
44+
if (sudo) this.headers['Sudo'] = sudo;
4245
}
4346
}
4447

0 commit comments

Comments
 (0)