feat: Add sudo abilities #203

This commit is contained in:
Justin 2018-10-09 19:01:19 -04:00
parent f2cc73ba07
commit 4bf574c0c0

View File

@ -8,6 +8,7 @@ interface BaseModelOptions {
oauthToken?: string;
useXMLHttpRequest?: boolean;
version?: string;
sudo?: boolean;
rejectUnauthorized?: boolean;
}
@ -23,6 +24,7 @@ class BaseModel {
constructor({
token,
oauthToken,
sudo,
url = 'https://gitlab.com',
useXMLHttpRequest = false,
version = 'v4',
@ -34,11 +36,12 @@ class BaseModel {
this.useXMLHttpRequest = useXMLHttpRequest;
this.rejectUnauthorized = rejectUnauthorized;
if (oauthToken) {
this.headers.authorization = `Bearer ${oauthToken}`;
} else if (token) {
this.headers['private-token'] = token;
}
// Handle auth tokens
if (oauthToken) this.headers.authorization = `Bearer ${oauthToken}`;
else if (token) this.headers['private-token'] = token;
// Set sudo
if (sudo) this.headers['Sudo'] = sudo;
}
}