Skip to content

Commit a5f5173

Browse files
committedOct 30, 2021
Update
1 parent a6f1da4 commit a5f5173

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed
 

‎public/libeyondea.png

79.7 KB
Loading

‎src/controllers/authController.js

+17
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,22 @@ export const signin = async (req, res) => {
3030
});
3131
};
3232

33+
export const current = async (req, res) => {
34+
const user = await User.getUserById(req.user.id);
35+
if (!user) {
36+
throw new APIError('User not found', httpStatus.NOT_FOUND);
37+
}
38+
return res.json({
39+
success: true,
40+
data: {
41+
firstName: user.firstName,
42+
lastName: user.lastName,
43+
userName: user.userName,
44+
avatarUrl: user.avatarUrl
45+
}
46+
});
47+
};
48+
3349
export const getMe = async (req, res) => {
3450
const user = await User.getUserByIdWithRoles(req.user.id);
3551
if (!user) {
@@ -138,6 +154,7 @@ export const resetPassword = async (req, res) => {
138154
export default {
139155
signup,
140156
signin,
157+
current,
141158
getMe,
142159
updateMe,
143160
logout,

‎src/routes/v1/authRoute.js

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const router = Router();
99

1010
router.post('/signup', validate(authValidation.signup), catchAsync(authController.signup));
1111
router.post('/signin', validate(authValidation.signin), catchAsync(authController.signin));
12+
router.get('/current', authenticate(), catchAsync(authController.current));
1213
router.get('/me', authenticate(), catchAsync(authController.getMe));
1314
router.put('/me', authenticate(), validate(authValidation.updateMe), catchAsync(authController.updateMe));
1415
router.post('/logout', validate(authValidation.logout), catchAsync(authController.logout));

0 commit comments

Comments
 (0)
Please sign in to comment.