Skip to content

Commit c926784

Browse files
Merge pull request #39 from dgraph-io/apoorv/support-multi-tenancy
Support multi tenancy
2 parents fa05a45 + c907f08 commit c926784

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

lib/clientStub.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export declare class DgraphClientStub {
1919
commit(ctx: TxnContext): Promise<TxnContext>;
2020
abort(ctx: TxnContext): Promise<TxnContext>;
2121
login(userid?: string, password?: string, refreshToken?: string): Promise<boolean>;
22+
loginIntoNamespace(userid?: string, password?: string, namespace?: number, refreshToken?: string): Promise<boolean>;
2223
logout(): void;
2324
getAuthTokens(): {
2425
accessToken?: string;

lib/clientStub.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,13 @@ var DgraphClientStub = (function () {
260260
return this.callAPI(url, __assign(__assign({}, this.options), { method: "POST" }));
261261
};
262262
DgraphClientStub.prototype.login = function (userid, password, refreshToken) {
263+
return __awaiter(this, void 0, void 0, function () {
264+
return __generator(this, function (_a) {
265+
return [2, this.loginIntoNamespace(userid, password, 0, refreshToken)];
266+
});
267+
});
268+
};
269+
DgraphClientStub.prototype.loginIntoNamespace = function (userid, password, namespace, refreshToken) {
263270
return __awaiter(this, void 0, void 0, function () {
264271
var body, res;
265272
return __generator(this, function (_a) {
@@ -281,6 +288,7 @@ var DgraphClientStub = (function () {
281288
else {
282289
body.userid = userid;
283290
body.password = password;
291+
body.namespace = namespace;
284292
}
285293
return [4, this.callAPI("login", __assign(__assign({}, this.options), { method: "POST", body: JSON.stringify(body) }))];
286294
case 1:

src/clientStub.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,21 @@ export class DgraphClientStub {
295295
userid?: string,
296296
password?: string,
297297
refreshToken?: string,
298+
): Promise<boolean> {
299+
return this.loginIntoNamespace(userid, password, 0, refreshToken);
300+
}
301+
302+
public async loginIntoNamespace(
303+
userid?: string,
304+
password?: string,
305+
namespace?: number,
306+
refreshToken?: string,
298307
): Promise<boolean> {
299308
if (this.legacyApi) {
300309
throw new Error("Pre v1.1 clients do not support Login methods");
301310
}
302311

303-
const body: { [k: string]: string } = {};
312+
const body: { [k: string ]: string | number} = {};
304313
if (
305314
userid === undefined &&
306315
refreshToken === undefined &&
@@ -316,6 +325,7 @@ export class DgraphClientStub {
316325
} else {
317326
body.userid = userid;
318327
body.password = password;
328+
body.namespace = namespace;
319329
}
320330

321331
const res: LoginResponse = await this.callAPI("login", {

0 commit comments

Comments
 (0)