diff --git a/.gitignore b/.gitignore index ef14a16..4406cc3 100644 --- a/.gitignore +++ b/.gitignore @@ -166,3 +166,5 @@ lerna-debug.log* # API Clients - Thunder Client thunder-tests thunder-tests/*.json +thunder-tests/ +/thunder-tests diff --git a/src/auth/dto/signup.dto.ts b/src/auth/dto/signup.dto.ts index e220736..5180b9d 100644 --- a/src/auth/dto/signup.dto.ts +++ b/src/auth/dto/signup.dto.ts @@ -5,6 +5,7 @@ import { IsString, IsStrongPassword, } from 'class-validator'; +import { Match } from 'src/common/decorators'; export class SignupDto { @IsString() @@ -30,4 +31,13 @@ export class SignupDto { example: 'Abcd@1234', }) password: string; + + @IsNotEmpty() + @IsStrongPassword() + @Match(SignupDto, o => o.password) + @ApiProperty({ + description: 'Confirm password', + example: 'Abcd@1234', + }) + confirmPassword: string; } diff --git a/src/common/decorators/index.ts b/src/common/decorators/index.ts index 3fc81f6..ed08de7 100644 --- a/src/common/decorators/index.ts +++ b/src/common/decorators/index.ts @@ -1,3 +1,4 @@ export * from './GetUser.decorator'; export * from './IsValidMongoId.decorator'; export * from './apiPaginatedResponse.decorator'; +export * from './match.decorator'; diff --git a/src/common/decorators/match.decorator.ts b/src/common/decorators/match.decorator.ts new file mode 100644 index 0000000..eac10b6 --- /dev/null +++ b/src/common/decorators/match.decorator.ts @@ -0,0 +1,38 @@ +import { ClassConstructor } from 'class-transformer'; +import { + ValidationArguments, + ValidationOptions, + ValidatorConstraint, + ValidatorConstraintInterface, + registerDecorator, +} from 'class-validator'; + +export const Match = ( + type: ClassConstructor, + property: (o: T) => any, + validationOptions?: ValidationOptions, +) => { + return (object: any, propertyName: string) => { + registerDecorator({ + target: object.constructor, + propertyName, + options: validationOptions, + constraints: [property], + validator: MatchConstraint, + }); + }; +}; + +@ValidatorConstraint({ name: 'Match' }) +export class MatchConstraint implements ValidatorConstraintInterface { + validate(value: any, args: ValidationArguments) { + const [fn] = args.constraints; + return fn(args.object) === value; + } + + defaultMessage(args: ValidationArguments) { + const [constraintProperty]: (() => any)[] = args.constraints; + const prop = constraintProperty.toString().split('. ')[1]; + return `${prop} and ${args.property} does not match`; + } +} diff --git a/thunder-tests/thunderActivity.json b/thunder-tests/thunderActivity.json deleted file mode 100644 index 0637a08..0000000 --- a/thunder-tests/thunderActivity.json +++ /dev/null @@ -1 +0,0 @@ -[] \ No newline at end of file diff --git a/thunder-tests/thunderCollection.json b/thunder-tests/thunderCollection.json deleted file mode 100644 index cf9cc20..0000000 --- a/thunder-tests/thunderCollection.json +++ /dev/null @@ -1,58 +0,0 @@ -[ - { - "_id": "72da743f-0e69-4866-bd34-1cba363db2fe", - "colName": "Cash-IOU", - "created": "2023-05-11T08:09:46.522Z", - "sortNum": 10000, - "folders": [ - { - "_id": "d51c1b96-b4d6-406b-bf7b-dda0d30f19df", - "name": "Auth", - "containerId": "", - "created": "2023-05-11T08:10:02.667Z", - "sortNum": 10000 - }, - { - "_id": "8f8f699b-44b0-4997-adbc-a5a673ed9648", - "name": "Transactions", - "containerId": "", - "created": "2023-05-11T08:10:11.441Z", - "sortNum": 20000 - }, - { - "_id": "56b704b7-a33b-4d7b-adf3-f86adb44a808", - "name": "Transaction rooms", - "containerId": "", - "created": "2023-05-14T10:19:30.344Z", - "sortNum": 30000 - } - ], - "settings": { - "options": { - "baseUrl": "http://localhost:5000" - }, - "envId": "e3ea7689-d386-4fde-bb52-bebddaed16e5" - } - }, - { - "_id": "c5c1f295-eebf-4390-8018-bbd9f1cc1e75", - "colName": "Cash-IOU-Production", - "created": "2023-05-29T03:36:24.398Z", - "sortNum": 20000, - "folders": [ - { - "_id": "7c55d5a7-c446-4c87-aea1-dc86d83469bd", - "name": "Authentication", - "containerId": "", - "created": "2023-05-29T03:36:37.767Z", - "sortNum": 10000 - } - ], - "settings": { - "options": { - "baseUrl": "https://cash-iou.adaptable.app" - }, - "envId": "177001a4-6703-4739-b8eb-549602993e77" - } - } -] \ No newline at end of file diff --git a/thunder-tests/thunderEnvironment.json b/thunder-tests/thunderEnvironment.json deleted file mode 100644 index 947d095..0000000 --- a/thunder-tests/thunderEnvironment.json +++ /dev/null @@ -1,34 +0,0 @@ -[ - { - "_id": "e3ea7689-d386-4fde-bb52-bebddaed16e5", - "name": "Cash-IOU", - "default": true, - "sortNum": 10000, - "created": "2023-05-11T08:08:40.797Z", - "modified": "2023-05-11T08:08:40.797Z", - "data": [ - { - "name": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjQ2MGI3MGRkOTMwZDcwZDNiNmQzZTM5IiwiaWF0IjoxNjg1MzMxMTU0LCJleHAiOjE2ODU5MzU5NTR9.y_g4yP86UcQAyXbq8DSeususZ9QdCp0yP68uk-Q45LI" - }, - { - "name": "alt_token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjQ2OWIwMTY4NjcxNWQ3MDA0MWEyZjg0IiwiaWF0IjoxNjg0NjQ3OTc2LCJleHAiOjE2ODUyNTI3NzZ9.MnwHM6hNay1D5IM0STjg9FaA-rXLXocmQhT02Lw8QNI" - } - ] - }, - { - "_id": "177001a4-6703-4739-b8eb-549602993e77", - "name": "Cash-IOU-Production", - "default": false, - "sortNum": 20000, - "created": "2023-05-29T03:37:04.962Z", - "modified": "2023-05-29T03:37:04.962Z", - "data": [ - { - "name": "token", - "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoiNjQ3NDFmNWM5OWNkM2E3ZWI2NTJhYWUwIiwiaWF0IjoxNjg1MzMxOTExLCJleHAiOjE2ODU5MzY3MTF9.DqzS6QTxUgWK9Zru41iXBoQJxGfy6hJDrkQcblvPpgk" - } - ] - } -] \ No newline at end of file diff --git a/thunder-tests/thunderclient.json b/thunder-tests/thunderclient.json deleted file mode 100644 index 23200a3..0000000 --- a/thunder-tests/thunderclient.json +++ /dev/null @@ -1,223 +0,0 @@ -[ - { - "_id": "c1b0c424-494d-4920-b99f-b9415abe519a", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "8f8f699b-44b0-4997-adbc-a5a673ed9648", - "name": "Get all transactions", - "url": "/api/transactions?roomId=6460b71dd930d70d3b6d3e3f&page=2", - "method": "GET", - "sortNum": 10000, - "created": "2023-05-11T08:10:31.609Z", - "modified": "2023-05-29T04:53:44.595Z", - "headers": [], - "params": [ - { - "name": "roomId", - "value": "6460b71dd930d70d3b6d3e3f", - "isPath": false - }, - { - "name": "page", - "value": "2", - "isPath": false - } - ], - "auth": { - "type": "bearer", - "bearer": "{{token}}" - }, - "tests": [] - }, - { - "_id": "efebe515-ea8a-4efd-b737-d20cc78468f4", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "8f8f699b-44b0-4997-adbc-a5a673ed9648", - "name": "Create new transaction", - "url": "{{URL}}/api/transactions", - "method": "POST", - "sortNum": 30000, - "created": "2023-05-11T08:12:47.139Z", - "modified": "2023-05-14T14:50:28.020Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"roomId\": \"6460b71dd930d70d3b6d3e3\",\n\n \"amount\": 45,\n \"note\":\"Biryani\",\n \"date\": \"2023-05-11T08:15:57.370Z\"\n}", - "form": [] - }, - "auth": { - "type": "bearer", - "bearer": "{{token}}" - }, - "tests": [] - }, - { - "_id": "3769791f-c9ca-4527-8ffc-97aad2c4c7a8", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "8f8f699b-44b0-4997-adbc-a5a673ed9648", - "name": "Get single transaction", - "url": "{{URL}}/api/transactions/6460bbe3ae5b419fac317f5f", - "method": "GET", - "sortNum": 40000, - "created": "2023-05-11T08:25:41.668Z", - "modified": "2023-05-27T03:04:45.168Z", - "headers": [], - "params": [], - "auth": { - "type": "bearer", - "bearer": "{{alt_token}}" - }, - "tests": [] - }, - { - "_id": "fc7776b0-58f6-4a44-b0bf-2ac6698c513c", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "8f8f699b-44b0-4997-adbc-a5a673ed9648", - "name": "Update a transaction", - "url": "", - "method": "GET", - "sortNum": 50000, - "created": "2023-05-11T08:39:12.220Z", - "modified": "2023-05-11T08:39:12.220Z", - "headers": [] - }, - { - "_id": "79db397b-90c1-4f8c-b865-2a7b16dd2c2c", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "d51c1b96-b4d6-406b-bf7b-dda0d30f19df", - "name": "Signup", - "url": "{{URL}}/api/auth/signup", - "method": "POST", - "sortNum": 60000, - "created": "2023-05-12T10:20:49.185Z", - "modified": "2023-05-27T02:01:45.761Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"name\": \"Rahul Mukharjee\",\n \"phone\": \"+918617008083\",\n \"password\": \"Abcd@1234\"\n}", - "form": [] - }, - "tests": [] - }, - { - "_id": "70d5bcf5-49bb-41b9-afa9-f7489f9f5f5e", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "d51c1b96-b4d6-406b-bf7b-dda0d30f19df", - "name": "Login", - "url": "/api/auth/login", - "method": "POST", - "sortNum": 70000, - "created": "2023-05-14T02:38:16.722Z", - "modified": "2023-05-29T04:04:24.241Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"phone\": \"+919851305775\",\n \"password\": \"Abcd@1234\"\n}", - "form": [] - }, - "auth": { - "type": "bearer", - "bearer": "{{token}}" - }, - "tests": [] - }, - { - "_id": "2d91ab50-ac1f-442f-866c-e743a7a03869", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "56b704b7-a33b-4d7b-adf3-f86adb44a808", - "name": "Create new room", - "url": "{{URL}}/api/transaction-room", - "method": "POST", - "sortNum": 80000, - "created": "2023-05-14T10:19:42.490Z", - "modified": "2023-05-15T01:29:57.355Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"name\": \"Rajib Kaka\",\n \"phone\": \"+916295605592\"\n}", - "form": [] - }, - "auth": { - "type": "bearer", - "bearer": "{{token}}" - }, - "tests": [] - }, - { - "_id": "ca900710-75bb-4be8-96b9-3fbb90bae4ec", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "56b704b7-a33b-4d7b-adf3-f86adb44a808", - "name": "Get all rooms", - "url": "{{URL}}/api/transaction-room/all", - "method": "GET", - "sortNum": 90000, - "created": "2023-05-15T01:29:18.302Z", - "modified": "2023-05-15T01:48:57.510Z", - "headers": [], - "params": [], - "auth": { - "type": "bearer", - "bearer": "{{alt_token}}" - }, - "tests": [] - }, - { - "_id": "a1484733-1805-4d85-95a3-72b8992c69d1", - "colId": "72da743f-0e69-4866-bd34-1cba363db2fe", - "containerId": "d51c1b96-b4d6-406b-bf7b-dda0d30f19df", - "name": "Who Am I", - "url": "/api/whoami", - "method": "GET", - "sortNum": 100000, - "created": "2023-05-29T03:28:56.447Z", - "modified": "2023-05-29T04:05:42.346Z", - "headers": [], - "params": [], - "auth": { - "type": "bearer", - "bearer": "{{token}}" - }, - "tests": [] - }, - { - "_id": "92c65bf5-8c97-4195-b3c3-cda30aba1c80", - "colId": "c5c1f295-eebf-4390-8018-bbd9f1cc1e75", - "containerId": "7c55d5a7-c446-4c87-aea1-dc86d83469bd", - "name": "Signup", - "url": "/api/auth/signup", - "method": "POST", - "sortNum": 10000, - "created": "2023-05-29T03:36:45.795Z", - "modified": "2023-05-29T03:43:25.347Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"name\": \"Sayed Ahmed\",\n \"phone\": \"+919851305775\",\n \"password\": \"5775#Cashiou\"\n}", - "form": [] - }, - "tests": [] - }, - { - "_id": "b9d1f724-62bd-442e-90c7-85370bef431d", - "colId": "c5c1f295-eebf-4390-8018-bbd9f1cc1e75", - "containerId": "7c55d5a7-c446-4c87-aea1-dc86d83469bd", - "name": "Login", - "url": "/api/auth/login", - "method": "POST", - "sortNum": 20000, - "created": "2023-05-29T03:44:06.570Z", - "modified": "2023-05-29T03:45:12.090Z", - "headers": [], - "params": [], - "body": { - "type": "json", - "raw": "{\n \"phone\": \"+919851305775\",\n \"password\": \"5775#Cashiou\"\n}", - "form": [] - }, - "tests": [] - } -] \ No newline at end of file