From 7672cd55300ef6676d92fdd266c279e491a66470 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Mon, 27 May 2024 12:27:57 -0700 Subject: [PATCH] Removed password from returned user, updated readme --- README.md | 62 ++++++++++++++++++++++++++++++++++++++ Server/db/MongoDB.js | 2 +- Server/routes/authRoute.js | 2 -- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a8e1b1f32..63f5625aa 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ BlueWave uptime monitoring application 4. [Endpoints](#endpoints) - POST [/api/v1/auth/register](#post-register) - POST [/api/v1/auth/login](#post-login) + - POST [/api/v1/auth/user/{userId}](#post-auth-user-edit-id) - GET [/api/v1/monitors](#get-monitors) - GET [/api/v1/monitor/{id}](#get-monitor-id) - GET [/api/v1/monitors/user/{userId}](#get-monitors-user-userid) @@ -222,6 +223,67 @@ curl --request POST \ --- +
+POST/api/v1/auth/user/{userId} + +###### Method/Headers + +> | Method/Headers | Value | +> | -------------- | ----- | +> | Method | POST | + +##### Body + +> | Name | Type | Notes | +> | ------------- | -------- | ----------- | +> | firstname | `string` | | +> | lastname | `string` | | +> | profilePicUrl | `string` | | +> | password | `string` | Min 8 chars | + +###### Response Payload + +> | Type | Notes | +> | ------ | ------------------------ | +> | `User` | Returns the updated user | + +##### Sample CURL request + +``` +curl --request POST \ + --url http://localhost:5000/api/v1/auth/user/6654d156634754f789e1f10e \ + --header 'Authorization: ' \ + --header 'Content-Type: application/json' \ + --data '{ + "firstname": "First Name", + "lastname: "Last Name" +}' +``` + +###### Sample Response + +```json +{ + "success": true, + "msg": "User updated", + "data": { + "_id": "6654d156634754f789e1f10e", + "firstname": "First Name", + "lastname": "Last Name", + "email": "me@gmail.com", + "isActive": true, + "isVerified": false, + "createdAt": "2024-05-27T18:30:46.358Z", + "updatedAt": "2024-05-27T19:21:51.747Z", + "__v": 0 + } +} +``` + +
+ +--- +
GET /api/v1/monitors diff --git a/Server/db/MongoDB.js b/Server/db/MongoDB.js index b3b269600..71b6fe44a 100644 --- a/Server/db/MongoDB.js +++ b/Server/db/MongoDB.js @@ -73,7 +73,7 @@ const updateUser = async (req, res) => { candidateUserId, candidateUser, { new: true } // Returns updated user instead of pre-update user - ); + ).select("-password"); return updatedUser; } catch (error) { throw error; diff --git a/Server/routes/authRoute.js b/Server/routes/authRoute.js index 94f0ce5cc..637e4bf5e 100644 --- a/Server/routes/authRoute.js +++ b/Server/routes/authRoute.js @@ -1,7 +1,5 @@ const router = require("express").Router(); -const user = require("../models/user"); const { verifyJWT } = require("../middleware/verifyJWT"); -const { verifyOwnership } = require("../middleware/verifyOwnership"); const { registerController,