We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 010cb80 commit 811e98fCopy full SHA for 811e98f
src/resolvers/blogResolvers.ts
@@ -102,12 +102,14 @@ export const blogResolvers = {
102
context.currentUser?._id
103
).populate("role");
104
105
- if (
106
- !userWithRole ||
107
- (userWithRole.role as any)?.roleName !== "applicant"
108
- ) {
109
- throw new CustomGraphQLError("Only Trainness can create blogs");
+ if (!userWithRole) {
+ throw new CustomGraphQLError("User not found or not logged in");
110
}
+ const roleName = (userWithRole.role as any)?.roleName;
+
+ if (!["applicant", "trainee"].includes(roleName)) {
111
+ throw new CustomGraphQLError("Only Trainness can create blogs");
112
+ }
113
try {
114
const existingRecord = await BlogModel.findOne({
115
title: args.blogFields.title,
0 commit comments