Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-06-2020 02:33 PM
Could someone help me understand how to reach out to my neo4j database to check if a user exists inside my custom resolver for login?
Mutation: {
register: async (_, { id, email, password }, context, info) => {
const hashedPassword = await bcrypt.hash(password, 10);
return neo4jgraphql(_, { id, email, password }, context, info);
},
login: async (_, { email, password }, context, info) => {
const user = //check neo4j database for existing user to log in
if (!user) {
return "user not found";
}
const valid = await bcrypt.compare(password, user.password);
if (!valid) {
return null;
}
const refreshToken = sign(
{ userId: user.id, count: user.count },
REFRESH_TOKEN_SECRET,
{
expiresIn: "30d"
}
);
const accessToken = sign({ userId: user.id }, ACCESS_TOKEN_SECRET, {
expiresIn: "1day"
});
context.res.cookie("refresh-token", refreshToken);
context.res.cookie("access-token", accessToken);
return user;
}
}
I'm not sure how to reach the database when you need more than simply calling neo4jgraphql() in the return of the resolver.
All the sessions of the conference are now available online