summaryrefslogtreecommitdiff
path: root/makima/frontend/src/contexts
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-11 04:11:06 +0000
committersoryu <soryu@soryu.co>2026-01-11 04:11:06 +0000
commit353918e05fb6455600fa2b15b44b2e8fea647760 (patch)
tree9c571878674d1d1a68e4534f05a9d26a9f7211ea /makima/frontend/src/contexts
parent3d15ec753f93babcc1fa0cf3958f1f164e98fea4 (diff)
downloadsoryu-353918e05fb6455600fa2b15b44b2e8fea647760.tar.gz
soryu-353918e05fb6455600fa2b15b44b2e8fea647760.zip
Add auth variables by default
Diffstat (limited to 'makima/frontend/src/contexts')
-rw-r--r--makima/frontend/src/contexts/AuthContext.tsx27
1 files changed, 3 insertions, 24 deletions
diff --git a/makima/frontend/src/contexts/AuthContext.tsx b/makima/frontend/src/contexts/AuthContext.tsx
index ce2724b..809c98a 100644
--- a/makima/frontend/src/contexts/AuthContext.tsx
+++ b/makima/frontend/src/contexts/AuthContext.tsx
@@ -6,7 +6,7 @@ import {
useCallback,
type ReactNode,
} from "react";
-import { supabase, isAuthConfigured, type Session, type User } from "../lib/supabase";
+import { supabase, isAuthConfigured, SUPABASE_URL, type Session, type User } from "../lib/supabase";
interface AuthState {
user: User | null;
@@ -42,16 +42,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
// Initialize auth state
useEffect(() => {
- if (!supabase) {
- // Auth not configured - allow unauthenticated access
- setState((prev) => ({
- ...prev,
- isLoading: false,
- isAuthenticated: true, // Allow access when auth is not configured
- }));
- return;
- }
-
// Get initial session
supabase.auth.getSession().then(({ data: { session } }) => {
setState({
@@ -84,9 +74,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const signIn = useCallback(
async (email: string, password: string): Promise<{ error: Error | null }> => {
- if (!supabase) {
- return { error: new Error("Auth not configured") };
- }
const { error } = await supabase.auth.signInWithPassword({ email, password });
return { error: error ? new Error(error.message) : null };
},
@@ -95,9 +82,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
const signUp = useCallback(
async (email: string, password: string): Promise<{ error: Error | null }> => {
- if (!supabase) {
- return { error: new Error("Auth not configured") };
- }
const { error } = await supabase.auth.signUp({ email, password });
return { error: error ? new Error(error.message) : null };
},
@@ -114,20 +98,15 @@ export function AuthProvider({ children }: { children: ReactNode }) {
}));
// Clear Supabase storage directly in case signOut API fails
- const storageKey = `sb-${import.meta.env.VITE_SUPABASE_URL?.split('//')[1]?.split('.')[0]}-auth-token`;
+ const storageKey = `sb-${SUPABASE_URL.split('//')[1]?.split('.')[0]}-auth-token`;
localStorage.removeItem(storageKey);
// Try to call signOut API (may fail if token is invalid, that's OK)
- if (supabase) {
- await supabase.auth.signOut({ scope: 'local' }).catch(() => {});
- }
+ await supabase.auth.signOut({ scope: 'local' }).catch(() => {});
}, []);
const signInWithOAuth = useCallback(
async (provider: "github" | "google"): Promise<{ error: Error | null }> => {
- if (!supabase) {
- return { error: new Error("Auth not configured") };
- }
const { error } = await supabase.auth.signInWithOAuth({
provider,
options: {