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:Infiniflow Ragflow Authorization Util

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

Overview

Concrete authentication state management API providing unified token storage and retrieval via localStorage for the RAGFlow frontend.

Description

The utils/authorization-util.ts module provides functions to get, set, and clear the authentication token in localStorage. It acts as the single source of truth for the user's authentication state in the browser.

Usage

Import these utilities in HTTP interceptors, auth guards, and login/logout handlers to manage authentication tokens.

Code Reference

Source Location

Signature

export function getAuthorization(): string | null;
export function setAuthorization(token: string): void;
export function clearAuthorization(): void;
export function isLoggedIn(): boolean;

Import

import { getAuthorization, setAuthorization, clearAuthorization } from '@/utils/authorization-util';

I/O Contract

Inputs

Name Type Required Description
token string Yes JWT auth token (for setAuthorization)

Outputs

Name Type Description
getAuthorization() string/null Current auth token or null
isLoggedIn() boolean Whether user has valid token

Usage Examples

import { setAuthorization, getAuthorization, clearAuthorization } from '@/utils/authorization-util';

// After login
setAuthorization(response.token);

// In HTTP interceptor
const token = getAuthorization();
if (token) headers['Authorization'] = `Bearer ${token}`;

// On logout
clearAuthorization();

Related Pages

Page Connections

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