Skip to content

Commit 98c3c22

Browse files
committed
Add loginInNamespace method
1 parent 5d5b28d commit 98c3c22

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

protos/api.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ message NQuad {
157157
string label = 5;
158158
string lang = 6;
159159
repeated Facet facets = 7;
160+
uint64 namespace = 8;
160161
}
161162

162163
message Value {
@@ -195,6 +196,7 @@ message LoginRequest {
195196
string userid = 1;
196197
string password = 2;
197198
string refresh_token = 3;
199+
uint64 namespace = 4;
198200
}
199201

200202
message Jwt {

src/clientStub.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,37 @@ export class DgraphClientStub {
9292
if (userid !== undefined) {
9393
req.setUserid(userid);
9494
req.setPassword(password);
95+
req.setNamespace(0);
96+
} else if (refreshJwt !== undefined) {
97+
// Use the caller-supplied refreshJwt
98+
req.setRefreshToken(refreshJwt);
99+
} else {
100+
req.setRefreshToken(this.refreshJwt);
101+
}
102+
const resp = await this.promisified.login(
103+
req,
104+
this.ensureMetadata(metadata),
105+
ensureCallOptions(options),
106+
);
107+
const jwtResponse = messages.Jwt.deserializeBinary(resp.getJson_asU8());
108+
this.accessJwt = jwtResponse.getAccessJwt();
109+
this.refreshJwt = jwtResponse.getRefreshJwt();
110+
return jwtResponse;
111+
}
112+
113+
public async loginIntoNamespace(
114+
userid?: string,
115+
password?: string,
116+
namespace?: number,
117+
refreshJwt?: string,
118+
metadata?: grpc.Metadata,
119+
options?: grpc.CallOptions,
120+
): Promise<messages.Jwt> {
121+
const req = new messages.LoginRequest();
122+
if (userid !== undefined) {
123+
req.setUserid(userid);
124+
req.setPassword(password);
125+
req.setNamespace(namespace);
95126
} else if (refreshJwt !== undefined) {
96127
// Use the caller-supplied refreshJwt
97128
req.setRefreshToken(refreshJwt);

0 commit comments

Comments
 (0)