VIBN Frontend for Coolify deployment
This commit is contained in:
37
app/api/test-token/route.ts
Normal file
37
app/api/test-token/route.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import { auth } from '@/lib/firebase/config';
|
||||
import { adminAuth } from '@/lib/firebase/admin';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Get current user from client-side auth
|
||||
const user = auth.currentUser;
|
||||
|
||||
if (!user) {
|
||||
return NextResponse.json({ error: 'Not authenticated' }, { status: 401 });
|
||||
}
|
||||
|
||||
// Get ID token
|
||||
const token = await user.getIdToken();
|
||||
|
||||
console.log('Token length:', token.length);
|
||||
console.log('User UID:', user.uid);
|
||||
|
||||
// Try to verify it with Admin SDK
|
||||
const decodedToken = await adminAuth.verifyIdToken(token);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
clientUid: user.uid,
|
||||
decodedUid: decodedToken.uid,
|
||||
match: user.uid === decodedToken.uid,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Token verification error:', error);
|
||||
return NextResponse.json({
|
||||
error: 'Token verification failed',
|
||||
details: error instanceof Error ? error.message : String(error),
|
||||
}, { status: 500 });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user