Skip to content

Instantly share code, notes, and snippets.

@jdecode
Created February 8, 2024 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdecode/2b90944f17f4c370cd5ef7f4f605430e to your computer and use it in GitHub Desktop.
Save jdecode/2b90944f17f4c370cd5ef7f4f605430e to your computer and use it in GitHub Desktop.
beta-version

Laravel Boilerplate [LBP] Docs

User Profile API

  1. 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'.
  2. 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.
  3. 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": "newemail@example.com" }.
    • 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.
  4. 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.

Authentication

  1. 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.
  2. 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).
  3. 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.
  4. 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.
  5. 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.

Profile Image Upload Feature

Features

  1. 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.

  2. 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.

  3. 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.

  4. 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

  1. 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 with null.

  2. 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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment