Skip to content

Commit

Permalink
2.5.7 really try to find a customer
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljonescodes committed Oct 27, 2023
1 parent ca319a6 commit 362c536
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/moa-square/guards/customers.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ export class CustomersGuard implements CanActivate {
});

if (!customer) {
customer = await this.service.createSaveAndSyncSquare({
userId: user.id,
merchantIdOrPath,
});
try {
customer = await this.service.createSaveAndSyncSquare({
userId: user.id,
merchantIdOrPath,
});
} catch {
customer = await this.service.findOneWithUserIdAndMerchantIdOrPath({
where: {
userId: user.id,
merchantIdOrPath,
},
});

if (!customer) {
throw new NotFoundException(translations.customersNotFound);
}
}
}

// Store customer object in request for later use
Expand Down

0 comments on commit 362c536

Please sign in to comment.