mirror of
https://github.com/apache/superset.git
synced 2024-09-12 00:29:39 -04:00
fix: roles undefined on public dashboards (#14648)
This commit is contained in:
parent
ba5d66cb0a
commit
884ded0507
@ -132,6 +132,13 @@ describe('canUserEditDashboard', () => {
|
|||||||
it('rejects nonexistent users', () => {
|
it('rejects nonexistent users', () => {
|
||||||
expect(canUserEditDashboard(dashboard, null)).toEqual(false);
|
expect(canUserEditDashboard(dashboard, null)).toEqual(false);
|
||||||
});
|
});
|
||||||
|
it('rejects missing roles', () => {
|
||||||
|
// in redux, when there is no user, the user is actually set to an empty object,
|
||||||
|
// so we need to handle missing roles as well as a missing user.s
|
||||||
|
expect(
|
||||||
|
canUserEditDashboard(dashboard, {} as UserWithPermissionsAndRoles),
|
||||||
|
).toEqual(false);
|
||||||
|
});
|
||||||
it('rejects "admins" if the admin role does not have edit rights for some reason', () => {
|
it('rejects "admins" if the admin role does not have edit rights for some reason', () => {
|
||||||
expect(
|
expect(
|
||||||
canUserEditDashboard(dashboard, {
|
canUserEditDashboard(dashboard, {
|
||||||
|
@ -48,6 +48,6 @@ export const canUserEditDashboard = (
|
|||||||
dashboard: Dashboard,
|
dashboard: Dashboard,
|
||||||
user?: UserWithPermissionsAndRoles | null,
|
user?: UserWithPermissionsAndRoles | null,
|
||||||
) =>
|
) =>
|
||||||
!!user &&
|
!!user?.roles &&
|
||||||
(isUserAdmin(user) || isUserDashboardOwner(dashboard, user)) &&
|
(isUserAdmin(user) || isUserDashboardOwner(dashboard, user)) &&
|
||||||
findPermission('can_write', 'Dashboard', user.roles);
|
findPermission('can_write', 'Dashboard', user.roles);
|
||||||
|
Loading…
Reference in New Issue
Block a user