From 09c6f31ff0c4c434d25a147eaac69f3877483d09 Mon Sep 17 00:00:00 2001 From: Damjan Savic Date: Sun, 25 Jan 2026 06:36:11 +0100 Subject: [PATCH] auto-claude: subtask-2-1 - Add JSDoc to auth.ts (checkAuth, signOut functions) --- src/utils/auth.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/utils/auth.ts b/src/utils/auth.ts index c57b754..3af825e 100644 --- a/src/utils/auth.ts +++ b/src/utils/auth.ts @@ -1,17 +1,33 @@ +/** + * Authentication Utility Functions + * Handles user authentication checks and sign out operations + */ + import { supabase } from './supabaseClient'; import { NavigateFunction } from 'react-router-dom'; +/** + * Check if user is authenticated + * Verifies the current session and redirects to login if not authenticated + * @param {NavigateFunction} navigate - React Router navigate function for redirects + * @returns {Promise} True if authenticated, false otherwise + */ export const checkAuth = async (navigate: NavigateFunction) => { const { data: { session } } = await supabase.auth.getSession(); - + if (!session) { navigate('/login'); return false; } - + return true; }; +/** + * Sign out current user + * Terminates the user session and redirects to login page + * @param {NavigateFunction} navigate - React Router navigate function for redirects + */ export const signOut = async (navigate: NavigateFunction) => { await supabase.auth.signOut(); navigate('/login');