MCPcopy Create free account
hub / github.com/alpha2phi/python-apps / login

Function login

hackernews/backend-nodejs/src/resolvers/Mutation.js:34–56  ·  view source on GitHub ↗
(parent, args, context, info)

Source from the content-addressed store, hash-verified

32}
33
34async function login(parent, args, context, info) {
35 const user = await context.prisma.user.findUnique({
36 where: { email: args.email }
37 });
38 if (!user) {
39 throw new Error('No such user found');
40 }
41
42 const valid = await bcrypt.compare(
43 args.password,
44 user.password
45 );
46 if (!valid) {
47 throw new Error('Invalid password');
48 }
49
50 const token = jwt.sign({ userId: user.id }, APP_SECRET);
51
52 return {
53 token,
54 user
55 };
56}
57
58async function vote(parent, args, context, info) {
59 const { userId } = context;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected