Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/api/auth/[...nextauth]/auth.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { NextAuthOptions } from 'next-auth';
import GoogleProvider from 'next-auth/providers/google';
import CredentialsProvider from 'next-auth/providers/credentials';
import { AuthService } from '@/services/auth.service';
import { AuthSharingService } from '@/services/auth-sharing.service';

// Debug flag - set to true to enable detailed authentication logging
const DEBUG_AUTH = true;
Expand Down Expand Up @@ -37,7 +36,6 @@ export const authOptions: NextAuthOptions = {
authToken: credentials.authToken,
};
} catch (error) {
AuthSharingService.removeSharedAuthToken();
return promptInvalidCredentials();
}
}
Expand Down
4 changes: 1 addition & 3 deletions app/api/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NextResponse } from 'next/server';
import { AuthSharingService } from '@/services/auth-sharing.service';

/**
* Gets the cookie prefix based on the environment
Expand All @@ -14,7 +13,7 @@ function getCookiePrefix(): string {
}

/**
* Handles the shared logout process by clearing the authentication cookies
* Handles the logout process by clearing the NextAuth cookies
* and redirecting to the callback URL or the origin.
*
* @param request - The HTTP request object
Expand All @@ -35,7 +34,6 @@ export async function GET(request: Request) {
'Set-Cookie': [
`${prefix}next-auth.session-token=; Expires=${expiredDate}; Path=/; HttpOnly; Secure`,
`${prefix}next-auth.csrf-token=; Expires=${expiredDate}; Path=/; HttpOnly; Secure`,
`${AuthSharingService.getAuthCookieName()}=; Expires=${expiredDate}; Path=/; Domain=${AuthSharingService.getParentDomain()}; HttpOnly; Secure`,
].join(', '),
},
});
Expand Down
88 changes: 0 additions & 88 deletions components/AuthSharingWrapper.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions components/menus/UserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { VerifiedBadge } from '@/components/ui/VerifiedBadge';
import { SwipeableDrawer } from '@/components/ui/SwipeableDrawer';
import { ResearchCoinIcon } from '@/components/ui/icons/ResearchCoinIcon';
import Link from 'next/link';
import { AuthSharingService } from '@/services/auth-sharing.service';
import { signOut } from 'next-auth/react';
import { navigateToAuthorProfile } from '@/utils/navigation';
import { Button } from '@/components/ui/Button';
import { useVerification } from '@/contexts/VerificationContext';
Expand Down Expand Up @@ -245,11 +245,11 @@ export default function UserMenu({

<div
className="px-6 py-2 hover:bg-gray-50"
onClick={() => AuthSharingService.signOutFromBothApps()}
onClick={() => signOut({ callbackUrl: '/' })}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
AuthSharingService.signOutFromBothApps();
signOut({ callbackUrl: '/' });
}
}}
tabIndex={0}
Expand Down Expand Up @@ -417,7 +417,7 @@ export default function UserMenu({
)}

<BaseMenuItem
onClick={() => AuthSharingService.signOutFromBothApps()}
onClick={() => signOut({ callbackUrl: '/' })}
className="w-full px-4 py-2"
>
<div className="flex items-center">
Expand Down
57 changes: 27 additions & 30 deletions components/providers/ClientProviders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { OnchainProvider } from '@/contexts/OnchainContext';
import { FollowProvider } from '@/contexts/FollowContext';
import { ClickProvider } from '@/contexts/ClickContext';
import { NavigationProvider } from '@/contexts/NavigationContext';
import { AuthSharingWrapper } from '@/components/AuthSharingWrapper';
import { VerificationProvider } from '@/contexts/VerificationContext';
import SignupModalContainer from '@/components/modals/SignupModalContainer';
import { ShareModalProvider } from '@/contexts/ShareContext';
Expand All @@ -40,35 +39,33 @@ export function ClientProviders({ children, session }: ClientProvidersProps) {
<OnchainProvider>
<NextAuthProvider session={session}>
<ReferralProvider>
<AuthSharingWrapper>
<AuthModalProvider>
<ShareModalProvider>
<UserProvider>
<VerificationProvider>
<ExchangeRateProvider>
<CurrencyPreferenceProvider>
<NotificationProvider>
<OrganizationProvider>
<PreferencesProvider>
<UserListsProvider>
<LeaderboardProvider>
<DismissedFeaturesProvider>
<FollowProvider>{children}</FollowProvider>
<FeatureNotifications />
</DismissedFeaturesProvider>
</LeaderboardProvider>
</UserListsProvider>
</PreferencesProvider>
</OrganizationProvider>
</NotificationProvider>
</CurrencyPreferenceProvider>
</ExchangeRateProvider>
</VerificationProvider>
</UserProvider>
<SignupModalContainer />
</ShareModalProvider>
</AuthModalProvider>
</AuthSharingWrapper>
<AuthModalProvider>
<ShareModalProvider>
<UserProvider>
<VerificationProvider>
<ExchangeRateProvider>
<CurrencyPreferenceProvider>
<NotificationProvider>
<OrganizationProvider>
<PreferencesProvider>
<UserListsProvider>
<LeaderboardProvider>
<DismissedFeaturesProvider>
<FollowProvider>{children}</FollowProvider>
<FeatureNotifications />
</DismissedFeaturesProvider>
</LeaderboardProvider>
</UserListsProvider>
</PreferencesProvider>
</OrganizationProvider>
</NotificationProvider>
</CurrencyPreferenceProvider>
</ExchangeRateProvider>
</VerificationProvider>
</UserProvider>
<SignupModalContainer />
</ShareModalProvider>
</AuthModalProvider>
</ReferralProvider>
</NextAuthProvider>
<ToasterProvider />
Expand Down
6 changes: 3 additions & 3 deletions contexts/UserContext.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
'use client';

import { createContext, useContext, ReactNode, useState, useEffect } from 'react';
import { useSession } from 'next-auth/react';
import { useSession, signOut } from 'next-auth/react';
import { AuthError, AuthService } from '@/services/auth.service';
import type { User } from '@/types/user';
import { AuthSharingService } from '@/services/auth-sharing.service';
import AnalyticsService from '@/services/analytics.service';
import { Experiment } from '@/utils/experiment';

Expand Down Expand Up @@ -39,7 +38,8 @@ export function UserProvider({ children }: { children: ReactNode }) {
} catch (err) {
if (err instanceof AuthError) {
if (err.code === 401) {
await AuthSharingService.signOutFromBothApps();
AnalyticsService.clearUserSession();
await signOut({ callbackUrl: '/' });
}
}
setError(err instanceof Error ? err : new Error('Failed to load user data'));
Expand Down
97 changes: 0 additions & 97 deletions services/auth-sharing.service.ts

This file was deleted.