-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.js
More file actions
109 lines (103 loc) · 2.69 KB
/
Copy pathuser.js
File metadata and controls
109 lines (103 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* Update the user routes to use the implemented controllers
*/
const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const { authenticateJWT, checkRole } = require('../middleware/auth');
/**
* @swagger
* /users/profile:
* get:
* summary: Get user profile
* tags: [Users]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: User profile retrieved successfully
* 401:
* description: Unauthorized
*/
router.get('/profile', authenticateJWT, userController.getProfile);
/**
* @swagger
* /users/profile:
* put:
* summary: Update user profile
* tags: [Users]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* name:
* type: string
* email:
* type: string
* format: email
* responses:
* 200:
* description: Profile updated successfully
* 400:
* description: Invalid input
* 401:
* description: Unauthorized
*/
router.put('/profile', authenticateJWT, userController.updateProfile);
/**
* @swagger
* /users/change-password:
* post:
* summary: Change user password
* tags: [Users]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - currentPassword
* - newPassword
* properties:
* currentPassword:
* type: string
* format: password
* newPassword:
* type: string
* format: password
* minLength: 8
* responses:
* 200:
* description: Password changed successfully
* 400:
* description: Invalid input
* 401:
* description: Unauthorized or incorrect current password
*/
router.post('/change-password', authenticateJWT, userController.changePassword);
/**
* @swagger
* /users:
* get:
* summary: Get all users (admin only)
* tags: [Users]
* security:
* - bearerAuth: []
* responses:
* 200:
* description: List of users
* 401:
* description: Unauthorized
* 403:
* description: Forbidden - Admin access required
*/
router.get('/', authenticateJWT, checkRole(['admin']), userController.getAllUsers);
module.exports = router;