Skip to content
Merged
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
18 changes: 14 additions & 4 deletions src/components/StandardNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ const DEFAULT_NOTIFICATION = {
receivedTime: '',
};

export function StandardNav({ guestAllowed, alignCenter = true }) {
export function StandardNav({ guestAllowed, alignCenter = true, animatedPoints, isPointsAnimating: propIsPointsAnimating }) {
const { role, points } = useContext(Context);

// Use animated points if provided, otherwise use regular points
const displayPoints = animatedPoints !== undefined ? animatedPoints : points;

// Use prop animation state if provided, otherwise track locally
const isPointsAnimating = propIsPointsAnimating !== undefined ? propIsPointsAnimating : false;

const [terminaIsOpen, setTerminalIsOpen] = useState(false);
const [upgradeModalOpen, setUpgradeModalOpen] = useState(false);
Expand Down Expand Up @@ -469,11 +475,15 @@ export function StandardNav({ guestAllowed, alignCenter = true }) {
)}

<div
className="tooltip mb-0 ml-4 flex cursor-pointer items-center space-x-2 rounded-lg px-4 py-1"
className={`tooltip mb-0 ml-4 flex cursor-pointer items-center space-x-2 rounded-lg px-4 py-1 transition-all duration-300 ${
isPointsAnimating ? 'ring-2 ring-green-400 shadow-lg shadow-green-400/20' : ''
}`}
style={{ backgroundColor: '#212121', borderWidth: '0px' }}
>
<h1 className="mx-auto mb-0 mt-0 text-center text-blue-500">
<i className="far fa-check-circle"></i> {points}
<h1 className={`mx-auto mb-0 mt-0 text-center transition-colors duration-300 ${
isPointsAnimating ? 'text-green-400' : 'text-blue-500'
}`}>
<i className="far fa-check-circle"></i> {displayPoints}
</h1>
</div>

Expand Down
2 changes: 1 addition & 1 deletion src/components/auth/AuthFooter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function AuthFooter() {
return (

<div className='text-neutral-500 text-sm mt-4 items-center justify-center'>
&copy; CTFGuide Corporation 2024 <br />
&copy; CTFGuide Corporation 2025 <br />
<div className='flex items-center'>
<Link href="/terms-of-service" target="_blank" rel="noopener noreferrer" className="text-sm text-blue-600 hover:text-blue-700 mr-2">Terms of Service</Link>
<Link href="/privacy-policy" target="_blank" rel="noopener noreferrer" className="text-sm text-blue-600 hover:text-blue-700 mr-2">Privacy Policy</Link>
Expand Down
6 changes: 6 additions & 0 deletions src/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ export function middleware(req) {
return NextResponse.next();
}

// Allow access to specific challenge pages (UUID format)
const challengePathRegex = /^\/challenges\/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/;
if (challengePathRegex.test(pathname)) {
return NextResponse.next();
}

const idToken = req.cookies.get('idToken');

// Redirect to login if token is missing or invalid
Expand Down
18 changes: 18 additions & 0 deletions src/pages/_app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,24 @@ export default function App({ Component, pageProps }) {
};

const fetchUser = async () => {
// Check if user has a token before making the request
const getCookie = () => {
try {
const value = `; ${document.cookie}`;
const parts = value.split(`; idToken=`);
if (parts.length === 2) return parts.pop().split(';').shift();
} catch (error) {
return "";
}
return "";
};

const token = getCookie();
if (!token) {
// No token, user is not authenticated - don't make the API call
return;
}

const url = process.env.NEXT_PUBLIC_API_URL + "/account";
const user = await request(url, "GET", null);

Expand Down
Loading