Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:FlowiseAI Flowise UseAuth

From Leeroopedia
Knowledge Sources
Domains Authentication, Authorization
Last Updated 2026-02-12 07:00 GMT

Overview

useAuth is a custom React hook that provides permission checking, workspace assignment validation, and feature display flag verification for the Flowise UI.

Description

The useAuth hook encapsulates authorization logic by reading from the Redux store (auth slice) and the ConfigContext. It exposes three utility functions: hasPermission for checking whether the current user holds a specific permission (or comma-separated list), hasAssignedWorkspace for verifying workspace membership, and hasDisplay for evaluating feature flag visibility. In open-source or global-admin mode, all permission and workspace checks return true by default.

Usage

Use this hook inside any React component that needs to conditionally render UI elements based on the current user's permissions, workspace assignment, or enabled feature flags. It is a foundational hook consumed by navigation components such as NavGroup and route guards like RequireAuth.

Code Reference

Source Location

Signature

export const useAuth = () => {
    // ...
    return { hasPermission, hasAssignedWorkspace, hasDisplay }
}

Import

import { useAuth } from '@/hooks/useAuth'

I/O Contract

Inputs

Name Type Required Description
(none) - - This hook takes no arguments; it reads from Redux store and ConfigContext internally.

Outputs

Name Type Description
hasPermission (permissionId: string) => boolean Returns true if the current user holds the given permission ID (supports comma-separated IDs). Always true in open-source or global-admin mode.
hasAssignedWorkspace (workspaceId: string) => boolean Returns true if the given workspaceId matches the user's active workspace. Always true in open-source or global-admin mode.
hasDisplay (display: string) => boolean Returns true if the named feature flag is present and enabled in the user's features object. Returns true when display is falsy.

Usage Examples

Basic Usage

import { useAuth } from '@/hooks/useAuth'

const MyComponent = () => {
    const { hasPermission, hasDisplay } = useAuth()

    if (!hasPermission('chatflows:view')) {
        return <p>You do not have access to chatflows.</p>
    }

    return (
        <div>
            <h1>Chatflows</h1>
            {hasDisplay('feat:evaluations') && <EvaluationsPanel />}
        </div>
    )
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment