[Admin UI]OneToMany field relate didn't work when login in AdminUI
See original GitHub issueBug report
Describe the bug
For example: User List:
keystone.createList('User', {
label: 'User',
fields: {
name: {
type: Text,
isUnique: true
},
email: {
type: Text,
},
password: {
type: Password
},
userGroup: {
type: Relationship,
ref: "Group.users"
}
},
});
UserGroup List:
keystone.createList('Group', {
label: 'UserGroup',
fields: {
name: {
type: Text,
isUnique: true
},
users: {
type: Relationship,
ref: "User.userGroup",
many: true,
},
enableSystem: {
type: Checkbox
},
});
authStrategy:
const authStrategy = keystone.createAuthStrategy({
type: PasswordAuthStrategy,
list: 'User',
});
AdminUI app:
new AdminUIApp({
authStrategy,
isAccessAllowed: ({
authentication: {
item: user,
listKey: list
}
}) => !!user && !!user.userGroup.enableSystem
})
Error:
TypeError: Cannot read property 'enableSystem' of undefined
at AdminUIApp.isAccessAllowed [as _isAccessAllowed] (/test/index.js:480:40)
at AdminUIApp.isAccessAllowed (/test/node_modules/@keystonejs/app-admin-ui/index.js:69:12)
at app.use (/test/node_modules/@keystonejs/app-admin-ui/index.js:201:23)
at Layer.handle [as handle_request] (/test/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/test/node_modules/express/lib/router/index.js:317:13)
at /rat query (/test/node_modules/express/lib/middleware/query.js:45:5)
at Layer.handle [as handle_request] (/test/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/root/topdocs/test/node_modules/express/lib/router/index.js:317:13)
at /root/topdocs/test/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/test/node_modules/express/lib/router/index.js:335:12)
at next (/test/node_modules/express/lib/router/index.js:275:10)
To Reproduce
open in browser
Expected behaviour
It can work.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: Windows
- Browser Chrome
Additional context
For avoid this bug, I have to add isAdmin field in User list 😦
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Django admin site not displaying ManyToManyField relationship
I've tried adding the TechInline class to the inlines list, but that causes a. 'TechInLine' not defined. Is that a straight copy-paste?
Read more >Django admin: how to enable add/edit buttons for many-to ...
My mistake was that I didn't register related model OfferGeo in admin.py . After adding admin.site.register(OfferGeo) add/edit buttons appeared.
Read more >FAQ: The admin - Django documentation
The admin site only allows access to users with those two fields both set to True. ... the filter for a ManyToManyField if...
Read more >How to Implement Multiple User Types with Django
A very common case is to have a regular user and an admin user. ... ManyToManyField(Quiz, through='TakenQuiz') interests = models.
Read more >Using the Admin Interface - Tutorial - Vskills
filter_horizontal and filter_vertical only work on ManyToManyField fields, not ForeignKey fields. By default, the admin site uses simple <select> boxes for ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes. In my testing the
userGroup
field only gives you the ID of theGroup
entry, not the actual group data.Pinging @MadeByMike since he added the
isAccessAllowed
feature.It looks like there hasn’t been any activity here in over 6 months. Sorry about that! We’ve flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. 😃