Routes - Auth

File Name : auth.js
File Path : /server/routes/auth.js
Auth route contains sendOtp, singnUp, checkUser, updateProfilePic, updateProfile, updateLocation, updateStatus routes. Also routes can be added which require authentication. These functionalities are included in Auth Controller.

Login Route

  1. API Path: api/auth/checkUser
  2. Method: POST
  3. Description: Login route verifies mobileNumber for the user. Once a user is authenticated, a token is generated.
  4. Parameters:

    • Name: req
    • Type: Object
    Name In Type Required
    mobileNumber req.body Number true
    loc req.body Array false
    userType req.body String true
    pushToken req.body String false
    playerId req.body String false
  5. Response: Returns an object with ten properties: success (bool), message, token, userName, mobileNumber, emailId, gpsLoc, profilePic, userId, isAvailable.

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    token string
    userName string
    mobileNumber number
    emailId string
    gpsLoc array
    profilePic string
    userId string
    isAvailable boolean

Send Otp Route

  1. API Path: api/auth/sendOtp
  2. Method: POST
  3. Description: This route is send an otp to user.
  4. Parameters:

    • Name: req
    • Type: Object
    Name In Type Required
    mobileNumber req.body Number true
  5. Response: Returns an object with three properties: success (bool), message, data. The third parameter data is an object with two properties: jwtAccessToken and user object.

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    otp number

SignUp Route

  1. API Path: api/auth/signUp
  2. Method: POST
  3. Description: SignUp route is used to register a new user. User can be either a user or a Driver and Once a user is register, a token is generated.
  4. Parameters:

    • Name: req
    • Type: Object
    Name In Type Required
    mobileNumber req.body Number true
    loc req.body Array false
    userType req.body String true
    name req.body String false
    emailId req.body String false
  5. Response: Returns an object with nine properties: success (bool), message, token, userName, mobileNumber, emailId, gpsLoc, profilePic, userId, isAvailable.

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    token string
    userName string
    mobileNumber number
    emailId string
    gpsLoc array
    profilePic string
    userId string

UpdateProfilePic Route

  1. API Path: api/auth/updateProfilePic
  2. Method: PUT
  3. Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
  4. Parameters:

    • Name: req
    • Type: Object

    • Name: jwtAccessToken

    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  5. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    data string

Update User Details Route

  1. API Path: api/auth/updateProfile
  2. Method: PUT
    1. Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
  3. Parameters:

    • Name: req
    • Type: Object
    Name Type
    userName String
    mobileNumber number
    emailId String
    • Name: jwtAccessToken
    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  1. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    data userObject

Update Gps Location Route

  1. API Path: api/auth/updateLoc
  2. Method: POST
  3. Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
  4. Parameters:

    • Name: req
    • Type: Object
    Name Type
    gpsLoc array
    • Name: jwtAccessToken
    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  1. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    data object

Delivery Boy UpdateAvailableStatus Route

  1. API Path: api/auth/updateStatus
  2. Method: POST
  3. Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
  4. Parameters:

    • Name: req
    • Type: Object
    Name Type
    isAvailable boolean
    • Name: jwtAccessToken
    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  1. Response:

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    data object

Admin Login Route

  1. API Path: api/auth/adminLogin
  2. Method: POST
  3. Description: Login route verifies emailId and Password for the admin. Once a admin is authenticated, a token is generated.
  4. Parameters:

    • Name: req
    • Type: Object
    Name In Type Required
    email req.body String true
    password req.body string true
    userType req.body String true
  5. Response: Returns an object with four properties: success (bool), message, token, data

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    token string
    data object

Create Admin Route

  1. API Path: api/auth/adminCreate
  2. Method: POST
  3. Description: Create Admin is protected route and creates new admin.
  4. Parameters:
    • Name: req
    • Type: Object
Name In Type Required
email req.body String true
password req.body string true
userType req.body String true
name req.body String true
  • Name: jwtAccessToken
  • In: Header
  • Type: String
  • Description: JWT access token is used to check the authenticity of the user.
  1. Response: Returns an object with three properties: success (bool), message, data

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    token string
    data object

Change Admin Password Route

  1. API Path: api/auth/changeAdminPassword
  2. Method: PUT
  3. Description: Change Admin Password is protected route and it change admin password.
  4. Parameters:
    • Name: req
    • Type: Object
Name In Type Required
oldPassword req.body String true
newPassword req.body string true
  • Name: jwtAccessToken
    • In: Header
    • Type: String
    • Description: JWT access token is used to check the authenticity of the user.
  1. Response: Returns an object with three properties: success (bool), message, data

    • Http Code: 200
    • Name: returnObj
    • Type: Object
    Name Type
    success boolean
    message string
    token string
    data object

results matching ""

    No results matching ""