Access operation function called with no session during successful login
Maintainers usually reply within 1 day
@tanishxdev is already working on this.
Since Jun 27, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- graphql, node.js, typescript
- Domain
- api, authentication, backend
Research direction
Reproduce the issue from the steps using the generated schema.ts and auth.ts, then run the supplied login mutation after logging out. Trace the authentication flow and the Company relationship query to compare the session used during login with the final authenticated session. Done means the access operation receives the final session data and the mutation result does not depend on the previous authentication state.
Written by the indexing model from the issue text.
Description
Hi,
The access operation function is been called with undefined session during a successful login. Here the steps to get where I am:
1.
Create and empty project with:
npm create keystone-app@latest
This creates a new project with:
"dependencies": {
"@keystone-6/auth": "^8.0.0",
"@keystone-6/core": "^6.0.0",
"@keystone-6/fields-document": "^9.0.0",
"typescript": "^5.5.0"
}
2.
Introduce the isAdmin checkbox, like shown in “Authentication and Access Control” guide. That means in schema.ts to add isAdmin field to the User list:
isAdmin: checkbox(),
and in auth.ts set
sessionData: 'id name isAdmin',
and
itemData: {isAdmin: true}
3.
Introduce the Company list defined as follows:
Company: list({
access: {
operation({ operation, session }){
const data = session?.data;
const userId = data?.id;
const isAdmin = data?.isAdmin;
return typeof userId == "string" && (isAdmin || operation == 'query');
}
},
fields: {
name: text(),
allowFeatureA: checkbox(),
allowFeatureB: checkbox(),
users: relationship({ ref: 'User.company', many: true }),
}
}),
This references a new relationship in User too:
company: relationship({ ref: 'Company.users', many: false }),
4.
That’s all. Now access the Admin UI and create a first admin user. Create a company for your user. Then logout and execute the following login:
mutation loginMutation($email: String!, $password: String!) {
authenticateUserWithPassword(email: $email, password: $password) {
... on UserAuthenticationWithPasswordSuccess {
item {
id
name
email
company {
id
name
allowFeatureA
allowFeatureB
}
}
}
}
}
providing the good email and password.
Expected behavior
- the
Companylist access operation is called with asessionwith loaded data. - the result of the mutation depends on final authentication state, not on previous authentication state.
Occurring behavior
- the
Companylist access operation is called with anundefinedsession. - the result of the mutation depends on previous authentication state, not on final authentication state.
Notes
- the
Companylist access operation is called withoperation=="query", which it is fine since it is not related to the running mutation but it is related to walking a relationship. - When I'm already logged in and I'm performing an useless login, it returns my company in
item.
Questions
- Is this the expected behavior from Keystone?
- How can I get session data as result of a successful login mutation?
Thanks a lot!
- Dominant language
- TypeScript
- Stars
- 10k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 38
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from keystonejs/keystone
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
keystonejs/keystone#10143 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
keystonejs/keystone#10141 ·
Maintainers usually reply within 1 day
-
[bug] List view search field becomes disabled when search returns no results, interrupting IME inputPossibly taken @ltxhhz claimed this 17 days ago. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
keystonejs/keystone#10097 ·
Maintainers usually reply within 1 day
-
Document Fields Demo page of docs refers to form that doesn't existMay be free again @Mthize claimed this 189 days ago, and no pull request is open. Open
Difficulty 1/5 Under an hour Newbie friendliness 72/100
keystonejs/keystone#9766 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 75/100
keystonejs/keystone#10142 ·
Maintainers usually reply within 1 day
All issues in keystonejs/keystone
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
better-auth/better-auth#13064 · 1 reaction ·
Maintainers usually reply within 1 day
-
Tell Sloppy how each kind of element plays on the timelinePossibly taken A pull request linked to this issue is open or already merged. Opengood first issue priority: medium size: XS task
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
bug P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug p1 subagents
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
discovery:other factory-active task-identify-harness-labels-done task-identify-issue-type-done
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
vercel/ai#25788 · 4 comments ·
Maintainers usually reply within 1 day