Fix: Spotify OAuth RLS integration, profile mapping, and robust AI playlist generation bypass
This commit is contained in:
@@ -6,12 +6,20 @@ interface AuthContextType {
|
||||
user: User | null;
|
||||
session: Session | null;
|
||||
loading: boolean;
|
||||
isDemoMode: boolean;
|
||||
isSpotifyAuthenticated: boolean;
|
||||
enableDemoMode: () => void;
|
||||
enableSpotifyMode: () => void;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<AuthContextType>({
|
||||
user: null,
|
||||
session: null,
|
||||
loading: true,
|
||||
isDemoMode: false,
|
||||
isSpotifyAuthenticated: false,
|
||||
enableDemoMode: () => {},
|
||||
enableSpotifyMode: () => {},
|
||||
});
|
||||
|
||||
export const useAuth = () => useContext(AuthContext);
|
||||
@@ -20,6 +28,21 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
const [user, setUser] = useState<User | null>(null);
|
||||
const [session, setSession] = useState<Session | null>(null);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [isDemoMode, setIsDemoMode] = useState(false);
|
||||
const [isSpotifyAuthenticated, setIsSpotifyAuthenticated] = useState(false);
|
||||
|
||||
const enableDemoMode = () => {
|
||||
setIsDemoMode(true);
|
||||
setIsSpotifyAuthenticated(false);
|
||||
setUser({ id: '00000000-0000-4000-8000-000000000002', email: 'demo@roadtripdj.com' } as User);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
const enableSpotifyMode = () => {
|
||||
setIsDemoMode(false);
|
||||
setIsSpotifyAuthenticated(true);
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
supabase.auth.getSession().then(({ data: { session } }) => {
|
||||
@@ -38,7 +61,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AuthContext.Provider value={{ user, session, loading }}>
|
||||
<AuthContext.Provider value={{ user, session, loading, isDemoMode, isSpotifyAuthenticated, enableDemoMode, enableSpotifyMode }}>
|
||||
{children}
|
||||
</AuthContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user