Skip to content

Commit 5ffe3da

Browse files
committed
chore: Remove hardcoded SSE token in AuthController
1 parent c422318 commit 5ffe3da

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/core/auth/auth.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class AuthController extends AbstractController {
2727
return res.status(HttpStatus.OK).json({
2828
...tokens,
2929
user,
30-
sseToken: 'hZcdVqHScVDsDFdHOdcjmufEKFJVKaS8', //TODO: change to real token
3130
});
3231
}
3332

@@ -38,6 +37,7 @@ export class AuthController extends AbstractController {
3837
return res.status(HttpStatus.OK).json({
3938
user: {
4039
...user,
40+
sseToken: 'hZcdVqHScVDsDFdHOdcjmufEKFJVKaS8', //TODO: change to real token
4141
},
4242
});
4343
}

src/core/backends/backends.service.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
BadRequestException,
3+
HttpException,
34
HttpStatus,
45
Injectable,
56
RequestTimeoutException,
@@ -55,7 +56,7 @@ export class BackendsService extends AbstractQueueProcessor {
5556
{ new: true },
5657
);
5758
if (isSyncedJob) {
58-
await this.identitiesService.model.findByIdAndUpdate(isSyncedJob.concernedTo.id, {
59+
await this.identitiesService.model.findByIdAndUpdate(isSyncedJob?.concernedTo?.id, {
5960
$set: {
6061
state: IdentityState.SYNCED,
6162
},
@@ -96,7 +97,7 @@ export class BackendsService extends AbstractQueueProcessor {
9697
},
9798
{ new: true },
9899
);
99-
await this.identitiesService.model.findByIdAndUpdate(failedJob.concernedTo.id, {
100+
await this.identitiesService.model.findByIdAndUpdate(failedJob?.concernedTo?.id, {
100101
$set: {
101102
state: IdentityState.ON_ERROR,
102103
},
@@ -115,8 +116,8 @@ export class BackendsService extends AbstractQueueProcessor {
115116
},
116117
{ upsert: true, new: true },
117118
);
118-
// console.log('completedJob', completedJob);
119-
await this.identitiesService.model.findByIdAndUpdate(completedJob.concernedTo.id, {
119+
console.log('completedJob', completedJob);
120+
await this.identitiesService.model.findByIdAndUpdate(completedJob?.concernedTo?.id, {
120121
$set: {
121122
state: IdentityState.SYNCED,
122123
},
@@ -142,17 +143,26 @@ export class BackendsService extends AbstractQueueProcessor {
142143

143144
const result = {};
144145
for (const identity of identities) {
145-
const [executedJob] = await this.executeJob(
146-
identity.action,
147-
identity.identity._id,
148-
{ identity },
149-
{
150-
...options,
151-
task: task._id,
152-
},
153-
);
154-
result[identity.identity._id] = executedJob;
146+
try {
147+
this.logger.debug(`Syncing identity ${identity.identity._id}`);
148+
const [executedJob] = await this.executeJob(
149+
identity.action,
150+
identity.identity._id,
151+
{ identity },
152+
{
153+
...options,
154+
task: task._id,
155+
},
156+
);
157+
result[identity.identity._id] = executedJob;
158+
} catch (err: HttpException) {
159+
this.logger.error(`Error while syncing identity ${identity.identity._id}`, err);
160+
result[identity.identity._id] = {
161+
...err.response,
162+
};
163+
}
155164
}
165+
156166
return result;
157167
}
158168

0 commit comments

Comments
 (0)