How can I filter and only allow users with isVerified === true to sign in? If it's false, the user should not be able to sign in through the mutation.
Here is my code for the mutation:
signin: async (
_: any,
{ credentials }: SignInArgs,
{ db }: Context
): Promise<UserPayloadType> => {
const { email, password } = credentials;
// Check if the user exists in the database
const user = await db.user.findUnique({
where: {
email,
},
});
if (!user) {
return {
userErrors: [
{
message: "There was a problem with your login",
},
],
token: null,
};
}
Mutation : activationAccount(emailAccount: String): ActivationAccountPayload!
Query:
type User {
id: ID!
username: String!
name: String!
isVerified: Boolean!
#this will update in the database on every signup
email: String
image: String
# likes: [LikedPost]!
posts(take: Int!, skip: Int!): [Post!]!
profession: [Profession!]!
}
Any help will be greatly appreciated. Please assist me :")🙏