Skip to main content
Glama

MCP Todoist

by kentaroh7777
AuthProvider.tsx1.8 kB
'use client'; import React, { createContext, useContext, useEffect, useState } from 'react'; import { AuthManager } from '../../lib/auth/auth-manager'; import { User } from '../../lib/auth/types'; interface AuthContextType { user: User | null; loading: boolean; signIn: (email: string, password: string) => Promise<void>; signUp: (email: string, password: string) => Promise<void>; signOut: () => Promise<void>; } interface AuthProviderProps { children: React.ReactNode; } const AuthContext = createContext<AuthContextType | undefined>(undefined); export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => { const [user, setUser] = useState<User | null>(null); const [loading, setLoading] = useState(true); const [authManager] = useState(() => new AuthManager()); useEffect(() => { const unsubscribe = authManager.onAuthStateChanged((user) => { setUser(user); setLoading(false); }); return unsubscribe; }, [authManager]); const signIn = async (email: string, password: string) => { const user = await authManager.signInWithEmail(email, password); setUser(user); }; const signUp = async (email: string, password: string) => { const user = await authManager.signUpWithEmail(email, password); setUser(user); }; const signOut = async () => { await authManager.signOut(); setUser(null); }; const value: AuthContextType = { user, loading, signIn, signUp, signOut, }; return ( <AuthContext.Provider value={value}> {children} </AuthContext.Provider> ); }; export const useAuth = () => { const context = useContext(AuthContext); if (context === undefined) { throw new Error('useAuth must be used within an AuthProvider'); } return context; };

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kentaroh7777/mcp-todoist'

If you have feedback or need assistance with the MCP directory API, please join our Discord server