reels
This commit is contained in:
@@ -302,18 +302,10 @@ const parseCourseContactInfo = (body) => {
|
||||
|
||||
const creatCourse = async (req, res, next) => {
|
||||
try {
|
||||
const token = req.header('Authorization').split(' ')[1]
|
||||
if (!token) return res.status(401).send('Access Denied')
|
||||
const decodedToken = jwt.verify(token, process.env.APP_SECRET)
|
||||
const userId = decodedToken.id
|
||||
|
||||
const user = await UserModel.findById(userId)
|
||||
if (!user) {
|
||||
return res.status(422).json({
|
||||
error: true,
|
||||
message: 'کاربر یافت نشد'
|
||||
})
|
||||
}
|
||||
// با blockCheck ست میشه (req.user) — برای کاربرِ زیرمجموعه، همون اکانتِ اصلیه
|
||||
// (نه خودِ زیرمجموعه)، پس آکادمی درست پیدا میشه
|
||||
const user = req.user
|
||||
const userId = user._id
|
||||
|
||||
const academy = await AcademyModel.findOne({ userId })
|
||||
if (!academy) {
|
||||
@@ -388,11 +380,9 @@ const creatCourse = async (req, res, next) => {
|
||||
|
||||
const updateCourse = async (req, res, next) => {
|
||||
try {
|
||||
const token = req.header('Authorization')?.split(' ')[1]
|
||||
if (!token) return res.status(401).send('Access Denied')
|
||||
|
||||
const decodedToken = jwt.verify(token, process.env.APP_SECRET)
|
||||
const userId = decodedToken.id
|
||||
// با blockCheck ست میشه (req.user) — برای کاربرِ زیرمجموعه، همون اکانتِ اصلیه
|
||||
const user = req.user
|
||||
const userId = user._id
|
||||
|
||||
const {
|
||||
price,
|
||||
@@ -422,14 +412,6 @@ const updateCourse = async (req, res, next) => {
|
||||
})
|
||||
}
|
||||
|
||||
const user = await UserModel.findById(userId)
|
||||
if (!user) {
|
||||
return res.status(422).json({
|
||||
error: true,
|
||||
message: 'کاربر یافت نشد'
|
||||
})
|
||||
}
|
||||
|
||||
const course = await CourseModel.findById(courseId)
|
||||
if (!course) {
|
||||
return res.status(422).json({
|
||||
|
||||
Reference in New Issue
Block a user