Skip to content

Authentication API

M♢NTΛSIM edited this page Aug 17, 2024 · 1 revision

Authentication API Documentation

Login

  • POST /login

    • Summary: Authenticates a user and returns a token.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "description": "Email address of the user."
            },
            "password": {
              "type": "string",
              "description": "Password of the user."
            }
          }
        }
    • Responses:
      • 200 OK: Authentication successful.
      • 401 Unauthorized: Authentication failed.
  • All Other Methods on /login

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Logout

  • GET /logout

    • Summary: Logs out a user and invalidates the session token.
    • Responses:
      • 200 OK: Logout successful.
      • 401 Unauthorized: User not logged in.
  • All Other Methods on /logout

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Request New Password

  • PUT /request-new-password

    • Summary: Initiates a password reset process for a user by sending them an email with a reset link.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "description": "Email address associated with the user account."
            }
          }
        }
    • Responses:
      • 200 OK: Reset email sent successfully.
      • 404 Not Found: No user found with this email.
  • All Other Methods on /request-new-password

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Resend Verification Email

  • GET /resend-verification/{id}

    • Summary: Resends the verification email to the user based on the user ID provided.
    • Parameters:
      • Path Parameter: id
        • Type: string
        • Description: Unique identifier of the user.
    • Responses:
      • 200 OK: Verification email resent successfully.
      • 404 Not Found: User not found.
  • All Other Methods on /resend-verification/{id}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Reset Password

  • PUT /reset-password/{token}

    • Summary: Allows a user to reset their password using a valid token received via email.
    • Parameters:
      • Path Parameter: token
        • Type: string
        • Description: Token received for resetting the password.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "newPassword": {
              "type": "string",
              "description": "New password for the user."
            },
            "confirmNewPassword": {
              "type": "string",
              "description": "Confirmation of the new password."
            }
          }
        }
    • Responses:
      • 200 OK: Password reset successfully.
      • 403 Forbidden: Invalid or expired token.
  • All Other Methods on /reset-password/{token}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Sign Up

  • POST /signup

    • Summary: Registers a new user and sends a verification email.
    • Request Body:
      • Content-Type: application/json
      • Schema:
        {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "description": "Email address for the new user."
            },
            "password": {
              "type": "string",
              "description": "Password for the new user."
            },
            "confirmPassword": {
              "type": "string",
              "description": "Confirmation of the password."
            }
          }
        }
    • Responses:
      • 201 Created: User registered successfully.
      • 409 Conflict: Email already in use.
      • 400 Bad Request: Invalid data provided.
  • All Other Methods on /signup

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Verify Email

  • GET /verify/{token}

    • Summary: Verifies a user's email using a token.
    • Parameters:
      • Path Parameter: token
        • Type: string
        • Description: Verification token sent to the user's email.
    • Responses:
      • 200 OK: Email verified successfully.
      • 403 Forbidden: Invalid or expired token.
  • All Other Methods on /verify/{token}

    • Summary: Handles unsupported methods.
    • Responses:
      • 405 Method Not Allowed: Method not supported.

Feel free to adjust any details or add additional information as needed!