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
- API Path: api/auth/checkUser
- Method: POST
- Description: Login route verifies mobileNumber for the user. Once a user is authenticated, a token is generated.
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 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
- API Path: api/auth/sendOtp
- Method: POST
- Description: This route is send an otp to user.
Parameters:
- Name: req
- Type: Object
Name In Type Required mobileNumber req.body Number true 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
- API Path: api/auth/signUp
- Method: POST
- 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.
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 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
- API Path: api/auth/updateProfilePic
- Method: PUT
- Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
Parameters:
- Name: req
Type: Object
Name: jwtAccessToken
- In: Header
- Type: String
- Description: JWT access token is used to check the authenticity of the user.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name Type success boolean message string data string
Update User Details Route
- API Path: api/auth/updateProfile
- Method: PUT
- Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
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.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name Type success boolean message string data userObject
Update Gps Location Route
- API Path: api/auth/updateLoc
- Method: POST
- Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
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.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name Type success boolean message string data object
Delivery Boy UpdateAvailableStatus Route
- API Path: api/auth/updateStatus
- Method: POST
- Description: This is a protected route which gets the user details through JWT access token which is provided in the header.
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.
Response:
- Http Code: 200
- Name: returnObj
- Type: Object
Name Type success boolean message string data object
Admin Login Route
- API Path: api/auth/adminLogin
- Method: POST
- Description: Login route verifies emailId and Password for the admin. Once a admin is authenticated, a token is generated.
Parameters:
- Name: req
- Type: Object
Name In Type Required email req.body String true password req.body string true userType req.body String true 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
- API Path: api/auth/adminCreate
- Method: POST
- Description: Create Admin is protected route and creates new admin.
- Parameters:
- Name: req
- Type: Object
Name | In | Type | Required |
---|---|---|---|
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.
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
- API Path: api/auth/changeAdminPassword
- Method: PUT
- Description: Change Admin Password is protected route and it change admin password.
- 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.
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