Skip to content

Commit bcc7122

Browse files
committed
added try catch to auth methods
1 parent f1bb0ac commit bcc7122

1 file changed

Lines changed: 58 additions & 46 deletions

File tree

‎src/lib/auth.ts‎

Lines changed: 58 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,25 @@ export class AuthAPI {
148148

149149
validateUserCredentials(credentials);
150150

151-
let res: { body: any; response?: IncomingMessage };
152-
153-
if (typeof credentials == 'string') {
154-
this.internalApi.accessToken = credentials;
155-
res = await this.internalApi.authControllerGetAllAccountRequests(
156-
undefined,
157-
undefined
158-
);
159-
} else {
160-
res = await this.internalApi.authControllerGetAllAccountRequests(
161-
credentials.password,
162-
credentials.email
163-
);
151+
try {
152+
let res: { body: any; response?: IncomingMessage };
153+
154+
if (typeof credentials == 'string') {
155+
this.internalApi.accessToken = credentials;
156+
res = await this.internalApi.authControllerGetAllAccountRequests(
157+
undefined,
158+
undefined
159+
);
160+
} else {
161+
res = await this.internalApi.authControllerGetAllAccountRequests(
162+
credentials.password,
163+
credentials.email
164+
);
165+
}
166+
return res.body;
167+
} catch (e) {
168+
throw e;
164169
}
165-
return res.body;
166170
}
167171

168172
async acceptAccountRequest(options: {
@@ -176,23 +180,27 @@ export class AuthAPI {
176180

177181
id = id.trim();
178182

179-
let res: { body: any; response?: IncomingMessage };
180-
181-
if (typeof credentials == 'string') {
182-
this.internalApi.accessToken = credentials;
183-
res = await this.internalApi.authControllerAcceptAccountRequest(
184-
id,
185-
undefined,
186-
undefined
187-
);
188-
} else {
189-
res = await this.internalApi.authControllerAcceptAccountRequest(
190-
id,
191-
credentials.password,
192-
credentials.email
193-
);
183+
try {
184+
let res: { body: any; response?: IncomingMessage };
185+
186+
if (typeof credentials == 'string') {
187+
this.internalApi.accessToken = credentials;
188+
res = await this.internalApi.authControllerAcceptAccountRequest(
189+
id,
190+
undefined,
191+
undefined
192+
);
193+
} else {
194+
res = await this.internalApi.authControllerAcceptAccountRequest(
195+
id,
196+
credentials.password,
197+
credentials.email
198+
);
199+
}
200+
return res.body;
201+
} catch (e) {
202+
throw e;
194203
}
195-
return res.body;
196204
}
197205

198206
async deleteAccountRequest(options: {
@@ -206,22 +214,26 @@ export class AuthAPI {
206214

207215
id = id.trim();
208216

209-
let res: { body: any; response?: IncomingMessage };
210-
211-
if (typeof credentials == 'string') {
212-
this.internalApi.accessToken = credentials;
213-
res = await this.internalApi.authControllerDeleteAccountRequest(
214-
id,
215-
undefined,
216-
undefined
217-
);
218-
} else {
219-
res = await this.internalApi.authControllerDeleteAccountRequest(
220-
id,
221-
credentials.password,
222-
credentials.email
223-
);
217+
try {
218+
let res: { body: any; response?: IncomingMessage };
219+
220+
if (typeof credentials == 'string') {
221+
this.internalApi.accessToken = credentials;
222+
res = await this.internalApi.authControllerDeleteAccountRequest(
223+
id,
224+
undefined,
225+
undefined
226+
);
227+
} else {
228+
res = await this.internalApi.authControllerDeleteAccountRequest(
229+
id,
230+
credentials.password,
231+
credentials.email
232+
);
233+
}
234+
return res.body;
235+
} catch (e) {
236+
throw e;
224237
}
225-
return res.body;
226238
}
227239
}

0 commit comments

Comments
 (0)