-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
good first issueGood for newcomersGood for newcomers📖 ・docsImprovements or additions to documentationImprovements or additions to documentation📺 ・tutorial candidate
Description
Using the example provided in the repo, I get the following error when trying to login to an auth provider (in this case Twitter). I believe the example is out of date as I have only changed the port and DB being used in the case of the example.
Field "email" is not defined by type "UserWhereUniqueInput".
This is marked in the URL as such:
Variable%20"%24where"%20got%20invalid%20value%20%7B%20email%3A%20"email%40email.com"%20%7D%3B%20Field%20"email"%20is%20not%20defined%20by%20type%20"UserWhereUniqueInput".
The keystone config file:
import 'dotenv/config';
import { config } from '@keystone-6/core';
import { statelessSessions } from '@keystone-6/core/session';
import Twitter from 'keystone-6-oauth/providers/twitter';
import { createAuth } from 'keystone-6-oauth';
import { KeystoneContext } from '@keystone-6/core/types';
import { lists } from './schemas';
import * as Path from 'path';
let sessionSecret = 'xxxxxxxxxx;
const dbURL = process.env.DATABASE_URL || "file:./keystone.db";
if (!sessionSecret) {
if (process.env.NODE_ENV === 'production') {
throw new Error(
'The SESSION_SECRET environment variable must be set in production'
);
} else {
sessionSecret = '-- DEV COOKIE SECRET; CHANGE ME --';
}
}
const sessionMaxAge = 60 * 60 * 24 * 30; // 30 days
const auth = createAuth({
listKey: 'User',
identityField: 'subjectId',
sessionData: `id name email`,
autoCreate: true,
resolver: async ({user}:{user: any}) => {
const username = user.name as string;
const email = user.email as string;
return { email, username };
},
keystonePath: '/admin',
sessionSecret,
providers: [
Twitter({
clientId: 'xxxxxxxxx',
clientSecret: 'xxxxxxxxxxxx',
}),
],
});
export default auth.withAuth(
// @ts-ignore
config({
server: {
port:3001
},
db: {
provider: "sqlite",
url: dbURL,
},
ui: {
isAccessAllowed: (context: KeystoneContext) => !!context.session?.data,
publicPages: ['/admin/auth/signin', '/admin/auth/error'],
getAdditionalFiles: [
async (config: any) =>
[
{
mode: 'copy',
inputPath: Path.join(__dirname, './customPages/signin.js'),
outputPath: 'pages/auth/signin.js',
},
{
mode: 'copy',
inputPath: Path.join(__dirname, './customPages/error.js'),
outputPath: 'pages/auth/error.js',
}
]
]
},
lists,
session: statelessSessions({
maxAge: sessionMaxAge,
secret: sessionSecret,
}),
})
);
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers📖 ・docsImprovements or additions to documentationImprovements or additions to documentation📺 ・tutorial candidate