-
Get Profile
- Endpoint:
GET /profile
- Description: Retrieves the profile of the authenticated user.
- Response: Returns a JSON object containing the user's profile information. The structure includes 'id', 'first_name', 'last_name', 'email', and 'email_verified_at'.
- Endpoint:
-
Update Profile
- Endpoint:
PATCH /profile
- Description: Updates the profile of the authenticated user.
- Request: Requires a JSON object with the fields to be updated. For example, to update the 'first_name', the request body should include
{ "first_name": "New Name" }
. - Response: Returns a JSON object containing the updated profile information and a success message. The 'users' table in the database is also updated with the new information.
- Endpoint:
-
Update Profile Email
- Endpoint:
PATCH /profile
- Description: Updates the email of the authenticated user.
- Request: Requires a JSON object with the new email. For example,
{ "email": "[email protected]" }
. - Response: Returns a JSON object containing the updated profile information and a success message. The 'email_verified_at' field is set to null after the email update. The 'users' table in the database is also updated with the new email.
- Endpoint:
-
Delete Profile
- Endpoint:
DELETE /profile
- Description: Deletes the profile of the authenticated user.
- Response: Returns a success message. The 'users' table in the database no longer contains the deleted user.
- Endpoint:
-
User Login
- Endpoint:
POST /login
- Description: Authenticates a user using their email and password.
- Request: Requires a JSON object with the user's email and password.
- Response: Returns a JSON object containing the user's profile information and a logged-in message. A personal access token with an expiration timestamp is created for the user.
- Endpoint:
-
Invalid Password
- Endpoint:
POST /login
- Description: Prevents a user from authenticating with an invalid password.
- Request: Requires a JSON object with the user's email and an incorrect password.
- Response: The user remains a guest (not authenticated).
- Endpoint:
-
User Logout
- Endpoint:
POST /logout
- Description: Logs out a user.
- Request: Requires the user's token in the Authorization header.
- Response: Returns a logged-out message.
- Endpoint:
-
Too Many Login Attempts
- Endpoint:
POST /login
- Description: Prevents a user from making too many login attempts.
- Request: Requires a JSON object with the user's email and an incorrect password.
- Response: After five failed attempts, the session has errors.
- Endpoint:
-
Too Many Password Reset Attempts
- Endpoint:
POST /password.email
- Description: Prevents a user from making too many password reset attempts.
- Request: Requires a JSON object with the user's email.
- Response: After three successful requests, the fourth request returns a 429 (Too Many Requests) status.
- Endpoint:
-
Upload and Delete Profile Image: This feature allows a user to upload a profile image. The image is stored in a specific path and a thumbnail is also created. The user can also delete the uploaded profile image. After deletion, the storage directory for the user is expected to be empty.
-
Restriction for Unverified Users: Unverified users (users who haven't verified their email) are not allowed to upload a profile image. If an unverified user tries to upload an image, the system will respond with a forbidden status.
-
File Size Limitation: The system restricts the size of the uploaded image. The maximum allowed size is 10 MB. If a user tries to upload an image larger than 10 MB, the system will respond with an invalid request status.
-
File Type Validation: The system only accepts image files for the profile picture. If a user tries to upload a non-image file (like a PDF), the system will respond with an invalid request status.
-
Image Status - Null: If a user hasn't uploaded a profile image, the status of the image upload will be
null
. The user can request the status of the image upload and the system will respond withnull
. -
Image Status - Processing: After a user has uploaded an image, the status of the image upload will be 'processing'. The user can request the status of the image upload and the system will respond with 'processing'.