diff --git a/docs/authentication.md b/docs/authentication.md index a7f5546..77fc050 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -88,6 +88,28 @@ curl -X 'POST' \ Email verification may also be required. ::: +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.firstname_should_be_string"` | When firstName is not a string | +| `"errors.firstname_too_short"` | When firstName is < 2 characters | +| `"errors.firstname_too_long"` | When firstName is > 20 characters | +| `"errors.lastname_should_be_string"` | When lastName is not a string | +| `"errors.lastname_too_short"` | When lastName is < 2 characters | +| `"errors.lastname_too_long"` | When lastName is > 20 characters | +| `"errors.invalid_age"` | When age is either not a number or is negative | +| `"errors.invalid_email"` | When email is invalid | +| `"errors.invalid_password"` | When password is not a string | +| `"errors.password_too_short"` | When password is < 8 characters | +| `"errors.password_too_long"` | When password is > 30 characters | +| `"errors.invalid_address"` | When address is not a string | +| `"errors.invalid_phone_number"` | When phone number is invalid (needs + and country code) | +| `"errors.invalid_zipcode"` | When zipcode is not a string | +| `"errors.invalid_avatar"` | When avatar url is not a url | +| `"errors.invalid_gender"` | When gender is not `'MALE'`, `'FEMALE'` or `'OTHER'` | +| `"errors.email_in_use"` | When email is already registered | + + ## Sign In - Method: `POST` @@ -120,6 +142,15 @@ curl -X 'POST' \ } ``` +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.incorrect_email_or_password"`| When the email or password is incorrect | +| `"errors.invalid_email"` | When the email is invalid | +| `"errors.should_provide_email"` | When the email is not sent with the request body | +| `"errors.invalid_email"` | When the password is not sent with the request body | + + ## Verify Email - Method: `POST` @@ -154,6 +185,12 @@ curl -X 'POST' \ The user will be required to follow the verification link sent to their email. ::: +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.invalid_email"` | When the email is invalid | +| `"errors.already_verified"` | When the email has already been verified | + ## Get Current User - Method: `GET` @@ -210,6 +247,10 @@ curl -X 'GET' \ -H 'accept: application/json' ``` +::: info NOTE +requires access token attatched either to cookies or `Authorization` header. +::: + ### Response ```json @@ -231,6 +272,12 @@ curl -X 'GET' \ } ``` +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.user_not_found"` | When a user could not be found with the given id | + + ## Get All Users - Method: `GET` @@ -249,6 +296,10 @@ curl -X 'GET' \ -H 'accept: */*' ``` +::: info NOTE +requires access token attatched either to cookies or `Authorization` header. +::: + ### Response ```json @@ -321,6 +372,12 @@ Response body Server must get someway refresh_token, it could be from body, cookie or header. ::: +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.token_not_found"` | When there is no refresh token in the body, cookie or header | + + ## Update User Data - Method: `PATCH` @@ -380,6 +437,8 @@ curl -X 'PATCH' \ } ``` +List of possible errors: Same as Sign Up + ## Recover Password - METHOD: `POST` @@ -415,6 +474,11 @@ This changes user's password into an automatically generated one which will be s The user then can access his account with it and optionally [change it](#change-password). ::: +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.invalid_email"` | When the email is invalid | + ## Change Password - Method: `PATCH` @@ -456,6 +520,16 @@ curl -X 'PATCH' \ This endpoint essentialy signs the user in again, hence the tokens in response. ::: +List of possible errors: +| Error | Condition | +| ------------------------------------- | ---------------------------------------------------------------- | +| `"errors.invalid_old_password"` | When the old password is not a string | +| `"errors.old_password_incorrect"` | When the old password is incorrect | +| `"errors.invalid_change_password"` | When the new password is not a string | +| `"errors.new_password_matches_old"` | When the new password is the same as the old one | +| `"errors.password_too_short"` | When the new password is shorter than 8 characters | +| `"errors.password_too_long"` | When the new password is longer than 30 characters | + ## Interface of JWT Token This [content](https://github.com/educata/everrest/blob/main/src/interfaces/user.interface.ts#L24) will be encoded inside the JWT token. diff --git a/docs/product.md b/docs/product.md index b9cb2f4..aee897d 100644 --- a/docs/product.md +++ b/docs/product.md @@ -155,7 +155,7 @@ curl -X 'GET' \ - `rating`: number - `price_min`: number - `price_max`: number -- `sort_by`: `"rating"`, `"price"`, `"isse_date"`, `"title"` +- `sort_by`: `"rating"`, `"price"`, `"issue_date"`, `"title"` - `sort_direction`: `"asc"`, `"desc"` ::: info NOTE diff --git a/src/modules/user/auth/guards/local-auth.guard.ts b/src/modules/user/auth/guards/local-auth.guard.ts index 0bb5e3b..9fb3f23 100644 --- a/src/modules/user/auth/guards/local-auth.guard.ts +++ b/src/modules/user/auth/guards/local-auth.guard.ts @@ -16,7 +16,7 @@ export class LocalAuthGuard extends AuthGuard('local') { if (!email && !password) { this.exceptionService.throwError( ExceptionStatusKeys.BadRequest, - 'Should be provide: Email and Password', + 'Should be provided: Email and Password', [ AuthExpectionKeys.ShouldProvideEmail, AuthExpectionKeys.ShouldProvidePassword, diff --git a/src/modules/user/dtos/sign-up.dto.ts b/src/modules/user/dtos/sign-up.dto.ts index c89f305..b490fc3 100644 --- a/src/modules/user/dtos/sign-up.dto.ts +++ b/src/modules/user/dtos/sign-up.dto.ts @@ -20,7 +20,7 @@ export class SignUpDto { message: AuthExpectionKeys.FirstnameTooShort, }) @MaxLength(API_CONFIG.MAX_FIRSTNAME_LENGTH, { - message: AuthExpectionKeys.LastnameTooLong, + message: AuthExpectionKeys.FirstnameTooLong, }) firstName: string;