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 AuthUtils

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

Overview

AuthUtils is a utility module that manages user authentication state by reading and writing user data, tokens, permissions, and features to localStorage and cookies.

Description

This module provides functions to get, update, and remove the current user from localStorage, clear all browser cookies, extract a normalized user object from a payload, and synchronize Redux state with localStorage upon authentication. It handles serialization/deserialization of user objects and manages multiple localStorage keys including isAuthenticated, isGlobal, isSSO, user, permissions, and features.

Usage

Use AuthUtils whenever you need to persist or retrieve authentication state on the client side, such as after login, logout, or when refreshing user session data. It is typically consumed by Redux reducers and authentication-related components.

Code Reference

Source Location

Signature

const AuthUtils = {
    getCurrentUser,
    updateCurrentUser,
    removeCurrentUser,
    updateStateAndLocalStorage,
    extractUser
}

export default AuthUtils

Import

import AuthUtils from '@/utils/authUtils'

I/O Contract

Inputs

Name Type Required Description
getCurrentUser() (none) N/A Reads the user key from localStorage and returns parsed JSON or undefined
updateCurrentUser(user) object or string Yes Stores the user in localStorage, stringifying if needed
removeCurrentUser() (none) N/A Clears all auth-related localStorage keys and cookies
extractUser(payload) object Yes Extracts normalized user fields (id, email, name, status, role, isSSO, activeOrganizationId, activeWorkspaceId, permissions, etc.)
updateStateAndLocalStorage(state, payload) object, object Yes Updates Redux state and writes auth data to localStorage

Outputs

Name Type Description
getCurrentUser return object or undefined The parsed user object from localStorage, or undefined if not present
extractUser return object A normalized user object with standard fields extracted from the payload

Usage Examples

Basic Usage

import AuthUtils from '@/utils/authUtils'

// Get current user
const user = AuthUtils.getCurrentUser()

// Update user after profile change
AuthUtils.updateCurrentUser({ ...user, name: 'New Name' })

// Logout - clear all auth state
AuthUtils.removeCurrentUser()

// In a Redux reducer after login
AuthUtils.updateStateAndLocalStorage(state, loginPayload)

Related Pages

Page Connections

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