SFU-Blueprint / Pedals

Apache License 2.0
0 stars 0 forks source link

/api/change-access-code does not follow the standard API format and has unnecessary checks #48

Closed dangminhduc1101 closed 1 month ago

dangminhduc1101 commented 1 month ago

Problem

There are three issues with /api/change-access-code:

  1. It does not follow the standard API format used in other routes.
  2. Password validation logic (length, numbers, and letters checks) is handled in the backend but should be managed in the frontend.
  3. A redundant folder exists at api/changecode, which needs to be removed.

Expected Format

Refer to: api/checkin/route.ts

Current Format

Refer to: api/change-access-code/route.ts

In the current code, there are checks for:

const minLength = 8;
const maxLength = 15;

const hasNumbers = (string: string) => /\d/.test(string);
const hasLetters = (string: string) => /[a-zA-Z]/.test(string);

These checks are better suited for the frontend to improve efficiency.

Instructions

  1. Pull the latest changes from the develop branch.
  2. Remove the redundant file and folder at api/changecode.
  3. Update the code in api/change-access-code/route.ts to match the format of api/checkin/route.ts. Comment out the password validation logic, keeping only the check that ensures the old password differs from the new one.
  4. Submit a pull request and tag @dangminhduc1101 for review.

Notes