-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.ts
41 lines (38 loc) · 1016 Bytes
/
auth.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import NextAuth, { DefaultSession } from "next-auth";
import Credentials from "next-auth/providers/credentials";
import { getClient } from "./apolloClient";
import { gql } from "@apollo/client";
const sampleQuery = gql`
query Dragon($dragonId: ID!) {
dragon(id: $dragonId) {
id
name
type
}
}
`;
export const { handlers, signIn, signOut, auth } = NextAuth({
providers: [
Credentials({
credentials: {
email: { label: "Email", type: "text" },
password: { label: "Password", type: "password" },
},
authorize: async (credentials) => {
console.log("AUTHORIZING...");
const { data } = await getClient().query({
query: sampleQuery,
variables: {
dragonId: "5e9d058759b1ff74a7ad5f8f",
},
});
console.log("Data: ", data);
return {
id: data.dragon.id,
name: data.dragon.name,
email: "[email protected]",
};
},
}),
],
});