fix(editor): Fix RBAC type errors (no-changelog) (#9435)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useUsersStore } from '@/stores/users.store';
|
||||
import { isAuthenticated } from '@/rbac/checks/isAuthenticated';
|
||||
import type { IUser } from '@/Interface';
|
||||
|
||||
vi.mock('@/stores/users.store', () => ({
|
||||
useUsersStore: vi.fn(),
|
||||
@@ -7,7 +8,7 @@ vi.mock('@/stores/users.store', () => ({
|
||||
|
||||
describe('Checks', () => {
|
||||
describe('isAuthenticated()', () => {
|
||||
const mockUser = { id: 'user123', name: 'Test User' };
|
||||
const mockUser: Partial<IUser> = { id: 'user123', fullName: 'Test User' };
|
||||
|
||||
it('should return true if there is a current user', () => {
|
||||
vi.mocked(useUsersStore).mockReturnValue({ currentUser: mockUser } as unknown as ReturnType<
|
||||
|
||||
@@ -5,7 +5,7 @@ import { isAuthenticated } from '@/rbac/checks';
|
||||
|
||||
export const authenticatedMiddleware: RouterMiddleware<AuthenticatedPermissionOptions> = async (
|
||||
to,
|
||||
from,
|
||||
_from,
|
||||
next,
|
||||
options,
|
||||
) => {
|
||||
|
||||
@@ -4,8 +4,8 @@ import type { DefaultUserMiddlewareOptions } from '@/types/rbac';
|
||||
import { isDefaultUser } from '@/rbac/checks';
|
||||
|
||||
export const defaultUserMiddleware: RouterMiddleware<DefaultUserMiddlewareOptions> = async (
|
||||
to,
|
||||
from,
|
||||
_to,
|
||||
_from,
|
||||
next,
|
||||
) => {
|
||||
const valid = isDefaultUser();
|
||||
|
||||
@@ -4,8 +4,8 @@ import type { EnterprisePermissionOptions } from '@/types/rbac';
|
||||
import { isEnterpriseFeatureEnabled } from '@/rbac/checks';
|
||||
|
||||
export const enterpriseMiddleware: RouterMiddleware<EnterprisePermissionOptions> = async (
|
||||
to,
|
||||
from,
|
||||
_to,
|
||||
_from,
|
||||
next,
|
||||
options,
|
||||
) => {
|
||||
|
||||
@@ -3,7 +3,11 @@ import { VIEWS } from '@/constants';
|
||||
import type { GuestPermissionOptions } from '@/types/rbac';
|
||||
import { isGuest } from '@/rbac/checks';
|
||||
|
||||
export const guestMiddleware: RouterMiddleware<GuestPermissionOptions> = async (to, from, next) => {
|
||||
export const guestMiddleware: RouterMiddleware<GuestPermissionOptions> = async (
|
||||
to,
|
||||
_from,
|
||||
next,
|
||||
) => {
|
||||
const valid = isGuest();
|
||||
if (!valid) {
|
||||
const redirect = to.query.redirect as string;
|
||||
|
||||
@@ -10,7 +10,7 @@ import { hasScope } from '@/rbac/checks';
|
||||
|
||||
export const rbacMiddleware: RouterMiddleware<RBACPermissionOptions> = async (
|
||||
to,
|
||||
from,
|
||||
_from,
|
||||
next,
|
||||
{ scope, options },
|
||||
) => {
|
||||
|
||||
@@ -4,8 +4,8 @@ import { VIEWS } from '@/constants';
|
||||
import { hasRole } from '@/rbac/checks';
|
||||
|
||||
export const roleMiddleware: RouterMiddleware<RolePermissionOptions> = async (
|
||||
to,
|
||||
from,
|
||||
_to,
|
||||
_from,
|
||||
next,
|
||||
checkRoles,
|
||||
) => {
|
||||
|
||||
Reference in New Issue
Block a user