diff --git a/src/models/blogModel.ts b/src/models/blogModel.ts index 34cf865..6b7468a 100644 --- a/src/models/blogModel.ts +++ b/src/models/blogModel.ts @@ -51,7 +51,7 @@ const blogSchema = new Schema({ isHidden: { type: Boolean, - default: false, + default: true, }, author: { type: Schema.Types.ObjectId, diff --git a/src/resolvers/blogResolvers.ts b/src/resolvers/blogResolvers.ts index 83483af..d3dcfaf 100644 --- a/src/resolvers/blogResolvers.ts +++ b/src/resolvers/blogResolvers.ts @@ -138,11 +138,6 @@ export const blogResolvers = { if (!userWithRole) { throw new CustomGraphQLError("User not found or not logged in"); } - const roleName = (userWithRole.role as any)?.roleName; - - if (!["applicant", "trainee"].includes(roleName)) { - throw new CustomGraphQLError("Only Trainness can create blogs"); - } try { const existingRecord = await BlogModel.findOne({ title: args.blogFields.title, @@ -188,13 +183,6 @@ export const blogResolvers = { throw new CustomGraphQLError("User not found or not logged in"); } - const roleName = (userWithRole.role as any)?.roleName; - - // Check if user has permission to update blogs - if (!["applicant", "trainee", "admin"].includes(roleName)) { - throw new CustomGraphQLError("You do not have permission to update blogs"); - } - try { // Check if blog exists const existingBlog = await BlogModel.findById(id); @@ -203,7 +191,7 @@ export const blogResolvers = { } // Optional: Check if user is the original author - if (roleName !== "admin" && existingBlog.author.toString() !== context.currentUser?._id.toString()) { + if (existingBlog.author.toString() !== context.currentUser?._id.toString()) { throw new CustomGraphQLError("You can only update your own blogs"); }