fix: prevent public access to inactive doctors #47
@@ -93,9 +93,13 @@ export const getAllDoctors = async (req, res) => {
|
|||||||
export const getDoctorByDoctorId = async (req, res) => {
|
export const getDoctorByDoctorId = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { doctorId } = req.params;
|
const { doctorId } = req.params;
|
||||||
|
const { admin } = req.query;
|
||||||
|
|
||||||
const doctor = await prisma.doctor.findUnique({
|
const doctor = await prisma.doctor.findFirst({
|
||||||
where: { doctorId },
|
where: {
|
||||||
|
doctorId,
|
||||||
|
...(admin === 'true' ? {} : { isActive: true }),
|
||||||
|
},
|
||||||
include: {
|
include: {
|
||||||
seo: true,
|
seo: true,
|
||||||
specializations: true,
|
specializations: true,
|
||||||
@@ -124,6 +128,7 @@ export const getDoctorByDoctorId = async (req, res) => {
|
|||||||
qualification: doctor.qualification,
|
qualification: doctor.qualification,
|
||||||
experience: doctor.experience,
|
experience: doctor.experience,
|
||||||
professionalSummary: doctor.professionalSummary,
|
professionalSummary: doctor.professionalSummary,
|
||||||
|
isActive: doctor.isActive,
|
||||||
seo: {
|
seo: {
|
||||||
seoTitle: doctor.seo?.seoTitle ?? '',
|
seoTitle: doctor.seo?.seoTitle ?? '',
|
||||||
metaDescription: doctor.seo?.metaDescription ?? '',
|
metaDescription: doctor.seo?.metaDescription ?? '',
|
||||||
@@ -648,9 +653,13 @@ export const getDoctorTimings = async (req, res) => {
|
|||||||
export const getDoctorTimingById = async (req, res) => {
|
export const getDoctorTimingById = async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { doctorId } = req.params;
|
const { doctorId } = req.params;
|
||||||
|
const { admin } = req.query;
|
||||||
|
|
||||||
const doctor = await prisma.doctor.findUnique({
|
const doctor = await prisma.doctor.findFirst({
|
||||||
where: { doctorId },
|
where: {
|
||||||
|
doctorId,
|
||||||
|
...(admin === 'true' ? {} : { isActive: true }),
|
||||||
|
},
|
||||||
include: {
|
include: {
|
||||||
departments: {
|
departments: {
|
||||||
include: {
|
include: {
|
||||||
|
|||||||
Reference in New Issue
Block a user