Files
imphnen-frontend-service/libs/service/src/hooks/auth/index.ts
T
Maulana SodiqinandClaude 1cb2443b58 fix: resolve circular dependency between utils and service libraries
Moved useAuthStore from utils to service to break circular dependency:
- utils was importing from service (supabase client, types)
- service was importing from utils (useAuthStore)
- Solution: moved useAuthStore and related storage utilities to service

Changes:
- Created libs/service/src/storage/ with cookies.ts and local-storage.ts
- Moved use-auth-store.ts from utils/hooks to service/hooks/auth
- Updated all 20+ files to import useAuthStore from service instead of utils
- Removed useAuthStore export from utils
- Added storage exports to service index

This fixes the build error: "Could not execute command because the task graph has a circular dependency"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 02:34:52 +07:00

75 lines
1.4 KiB
TypeScript

import { supabase } from '../../supabase';
export * from './use-auth-store';
// Supabase GitHub OAuth hook
export const useGitHubAuth = () => {
const signInWithGitHub = async () => {
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github',
options: {
redirectTo: `${globalThis.location.origin}/auth/callback`,
},
});
if (error) {
throw error;
}
// Return the OAuth URL for debugging
return data;
};
return {
signInWithGitHub,
};
};
// Supabase Email/Password authentication hook
export const useEmailAuth = () => {
const signInWithEmail = async (email: string, password: string) => {
const { data, error } = await supabase.auth.signInWithPassword({
email,
password,
});
if (error) {
throw error;
}
return data;
};
const signUpWithEmail = async (email: string, password: string, fullname: string) => {
const { data, error } = await supabase.auth.signUp({
email,
password,
options: {
data: {
full_name: fullname,
},
},
});
if (error) {
throw error;
}
return data;
};
const signOut = async () => {
const { error } = await supabase.auth.signOut();
if (error) {
throw error;
}
};
return {
signInWithEmail,
signUpWithEmail,
signOut,
};
};