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:
2025-01-03 17:45:09 +03:30
parent bda5bca9de
commit 465b678357
11 changed files with 180 additions and 12 deletions
+11
View File
@@ -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)