Skip to content

Commit

Permalink
2.5.11 fix duplicate customers bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljonescodes committed Dec 18, 2023
1 parent a6cc871 commit 46e44b5
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 41 deletions.
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
{
"author": "Paul Jones",
"dependencies": {
"@aws-sdk/client-s3": "^3.470.0",
"@aws-sdk/client-s3": "^3.474.0",
"@nestjs-modules/mailer": "^1.9.1",
"@nestjs/axios": "^3.0.1",
"@nestjs/common": "^10.2.10",
"@nestjs/common": "^10.3.0",
"@nestjs/config": "^3.1.1",
"@nestjs/core": "10.2.10",
"@nestjs/core": "10.3.0",
"@nestjs/event-emitter": "^2.0.3",
"@nestjs/jwt": "10.2.0",
"@nestjs/passport": "10.0.3",
"@nestjs/platform-express": "10.2.10",
"@nestjs/platform-express": "10.3.0",
"@nestjs/schedule": "^4.0.0",
"@nestjs/swagger": "7.1.16",
"@nestjs/swagger": "7.1.17",
"@nestjs/terminus": "^10.2.0",
"@nestjs/typeorm": "10.0.1",
"@sentry/node": "^7.86.0",
"@sentry/node": "^7.88.0",
"apple-signin-auth": "1.7.5",
"bcryptjs": "2.4.3",
"class-transformer": "0.5.1",
"class-validator": "0.14.0",
"date-fns": "^2.30.0",
"date-fns": "^3.0.0",
"date-fns-tz": "^2.0.0",
"dotenv": "^16.3.1",
"env-cmd": "^10.1.0",
Expand All @@ -37,20 +37,20 @@
"nestjs-s3": "^2.1.0-next.1",
"nestjs-spelunker": "^1.3.0",
"nestjs-twilio": "^4.2.0",
"newrelic": "^11.6.1",
"newrelic": "^11.7.0",
"nodemailer": "6.9.7",
"nodemailer-mailgun-transport": "^2.1.5",
"passport": "0.7.0",
"passport-anonymous": "1.0.1",
"passport-headerapikey": "^1.2.2",
"passport-jwt": "4.0.1",
"pg": "8.11.3",
"reflect-metadata": "0.1.14",
"reflect-metadata": "0.2.1",
"rimraf": "^5.0.5",
"rxjs": "7.8.1",
"source-map-support": "0.5.21",
"square": "^33.0.0",
"stripe": "^14.8.0",
"square": "^33.1.0",
"stripe": "^14.9.0",
"swagger-ui-express": "5.0.0",
"tsconfig-paths": "^4.2.0",
"typeorm": "0.3.17",
Expand All @@ -60,24 +60,24 @@
"devDependencies": {
"@nestjs/cli": "10.2.1",
"@nestjs/schematics": "10.0.3",
"@nestjs/testing": "10.2.10",
"@nestjs/testing": "10.3.0",
"@types/bcryptjs": "^2.4.6",
"@types/express": "4.17.21",
"@types/inline-css": "^3.0.3",
"@types/jest": "29.5.11",
"@types/ms": "^0.7.34",
"@types/multer": "1.4.11",
"@types/node": "20.10.4",
"@types/node": "20.10.5",
"@types/nodemailer": "^6.4.14",
"@types/nodemailer-mailgun-transport": "^1.4.6",
"@types/passport-anonymous": "1.0.5",
"@types/passport-jwt": "3.0.13",
"@types/supertest": "2.0.16",
"@typescript-eslint/eslint-plugin": "6.13.2",
"@typescript-eslint/parser": "6.13.2",
"eslint": "8.55.0",
"@typescript-eslint/eslint-plugin": "6.15.0",
"@typescript-eslint/parser": "6.15.0",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.29.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-prettier": "5.0.1",
"husky": "8.0.3",
"hygen": "6.2.11",
Expand Down Expand Up @@ -150,5 +150,5 @@
"typeorm": "node --loader ts-node/esm -r tsconfig-paths/register ./node_modules/typeorm/cli.js"
},
"type": "module",
"version": "2.5.10"
"version": "2.5.11"
}
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async function bootstrap() {
app,
new DocumentBuilder()
.setTitle('MyOrderApp Square API')
.setVersion('2.5.10')
.setVersion('2.5.11')
.addBearerAuth()
.addApiKey(
{ type: 'apiKey', name: config.headerApiKey, in: 'header' },
Expand Down Expand Up @@ -126,7 +126,7 @@ async function bootstrap() {
app,
new DocumentBuilder()
.setTitle('MyOrderApp Admin API')
.setVersion('2.5.10')
.setVersion('2.5.11')
.addBearerAuth()
.addApiKey(
{ type: 'apiKey', name: config.headerApiKey, in: 'header' },
Expand Down
42 changes: 21 additions & 21 deletions src/moa-square/guards/customers.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,35 +58,35 @@ export class CustomersGuard implements CanActivate {
}
request.user = user;

let customer = await this.service.findOneWithUserIdAndMerchantIdOrPath({
const customer = await this.service.findOneWithUserIdAndMerchantIdOrPath({
where: {
userId: user.id,
merchantIdOrPath,
},
});

/*
* This fix is dedicated to Michael Ryan Bearce
*/
if (!customer) {
try {
customer = await this.service.createSaveAndSyncSquare({
userId: user.id,
merchantIdOrPath,
});
} catch {
customer = await this.service.findOneWithUserIdAndMerchantIdOrPath({
where: {
userId: user.id,
merchantIdOrPath,
},
});
// /*
// * This fix is dedicated to Michael Ryan Bearce
// */
// if (!customer) {
// 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);
}
}
if (!customer) {
throw new NotFoundException(translations.customersNotFound);
}
// }
// }

// Store customer object in request for later use
request.customer = customer;
Expand Down

0 comments on commit 46e44b5

Please sign in to comment.