FIX: UserSeeder
ADD: Get-Self endpoint for users ADD: Category and Role Seeder FIX: Login Check Bug ADD: Extra fields for documents and images in belonging model ADD: localhost:5173 to cors ADD: SuperAdmin ID to env
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// userController.js
|
||||
const catchAsync = require('../../globalErrorHandler/catchAsync')
|
||||
const userService = require('./userService')
|
||||
const AppError = require("../../globalErrorHandler/AppError");
|
||||
|
||||
exports.signup = catchAsync(async (req, res, next) => {
|
||||
const { user, token, cookieOptions } = await userService.signup(
|
||||
@@ -55,6 +56,16 @@ exports.getAllUsers = catchAsync(async (req, res, next) => {
|
||||
})
|
||||
})
|
||||
|
||||
exports.userGetSelf = catchAsync(async (req, res, next) => {
|
||||
const user = req.user
|
||||
if (!user) {
|
||||
throw new AppError('NotLoggedIn', 403, {})
|
||||
}
|
||||
return res.status(200).json({ status: 'success ', data: { user } })
|
||||
})
|
||||
|
||||
|
||||
|
||||
exports.getUser = catchAsync(async (req, res, next) => {
|
||||
const user = await userService.getUser(req.params.userId)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user