Skip to content

Latest commit

 

History

History
287 lines (253 loc) · 7.11 KB

Api-doc.md

File metadata and controls

287 lines (253 loc) · 7.11 KB

File-Auth

Codepeak 2021 Open source

Issues GitHub pull requests


Python Django MySQL React
JWT HTML5 CSS3 Postman Visual Studio Code GitHub
A secure-authentication system which verifies users by verifying an uploaded file.

Api Documentation:

Endpoints:-

1 Register

  • For registering a new user

  • URL

    POST /api/register
  • Request body structure

    Parameter Type Required Description
    name string Required Your Name
    email string Required Your Email
    password string Required Your password
    age string Required Your Age
    phoneno string Required Your Phone Number
  • Example Input

    {
      "name" : "demo",
      "email" : "[email protected]",
      "password" : "demo@123",
      "age" : 19,
      "phoneno" : 9999999999
    }
  • Example Response on success

    {
        "serializer" : {
          "name" : "demo",
          "email" : "[email protected]",
          "password" : "demo@123",
          "age" : 19,
          "phoneno" : 9999999999
        }
        "status" : 201,
        "message" : "User Created Successfull"
    }
  • Example Response on using registered email

    {
        "email" : [
            "user with this email already exists"
          ]
    }

2 Login

  • For logging in a user

  • URL

    POST /api/login
  • Request body structure

    Parameter Type Required Description
    email string Required Your Email
    password string Required Your password
  • Example Input

    {
      "email" : "[email protected]",
      "password" : "demo@123",
    }
  • Example Response on success

    {
        "message" : "Successfully logged in",
        "status" : 200
    }
  • Example Response on Wrong Password

    {
        "message" : "You have Entered Incorrect Password",
        "status" : 403
    }
  • Example Response on Wrong Email

    {
        "message" : "No User found",
        "status" : 403
    }
  • Remarks:

    • jwt token is saved in Cookies and sent to server on every request
    • if the token expires/is_invalid, then we have to login again

3 Get User Details

  • For getting user data

  • URL

    GET /api/user
  • Request body structure

    Parameter Type Required Description
    none none none
  • Example Input

    {}
  • Example Response on success

    {
        "message" : {
            "id" : 1,
            "name" : "demo",
            "email" : "[email protected]",
            "age" : 19,
            "phoneno" : 9999999999
          },
        "status" : 200
    }
  • Remarks:

    • server send your user details by analysing your jwt token which is automatically send in cookies

4 Update User Details

  • For updating user data

  • URL

    POST /api/profile
  • Request body structure

    Parameter Type Required Description
    name string Not Required Your Name
    age string Not Required Your Age
    phoneno string Not Required Your Phone Number
  • Example Input

    {
      "name" : "demo updated",
      "age" : 20,
    }
  • Example Response on success

    {
        "message": "Your Profile Updated Successfully",
        "status":200
    }

5 Logout

  • For Signing out the current logged in user

  • URL

    POST /api/logout
  • Request body structure

    Parameter Type Required Description
    none none none
  • Example Input

    {}
  • Example Response on success

    {
        "message" : "success"
    }
  • Remarks:

    • on logout, the jwt token is deleted from Cookies.

6 Upload an Image

  • For Uploading the images

  • URL

    POST /api/upload
  • Request body structure

    Parameter Type Required Description
    user int Required user id
    title string Required image name
    image image Required image to be uploaded
  • Example Input and Response

    upload image

7 List all Images

  • For Listing all the images

  • URL

    GET /api/listview
  • Request body structure

    Parameter Type Required Description
    none none none
  • Example Input and Response

    upload image

8 Deleting a Image

  • For Deleting the images

  • URL

    POST /api/deleteimage
  • Request body structure

    Parameter Type Required Description
    id int Required id of image
    image string Required id of image
  • Example Input and Response upload image

  • Example Response on mismatch of user & image relation

    {
        "message":"Can't delete other user's image"
    }

9 Downloading a Image

  • For Downloading the images

  • URL

    GET /img_uploads/<path:relative_path>
  • Request body structure

    Parameter Type Required Description
    none none none
  • Example Input and Response upload image