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
11 changes: 0 additions & 11 deletions .gitattributes

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@auth0/nextjs-auth0": "^3.5.0",
"chart.js": "^4.4.7",
"cookies-next": "^5.0.2",
"next": "15.0.2",
"next": "15.0.7",
"next-intl": "^3.25.3",
"plotly.js": "^3.0.1",
"react": "19.0.0-rc-02c0e824-20241028",
Expand Down
14 changes: 12 additions & 2 deletions src/app/api/auth/[auth0]/route.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { handleAuth } from '@auth0/nextjs-auth0';
import { handleAuth, handleLogin } from "@auth0/nextjs-auth0";

export const GET = handleAuth();
export const GET = handleAuth({
login: handleLogin({
returnTo: "/chat",
}),
signup: handleLogin({
authorizationParams: {
screen_hint: "signup",
},
returnTo: "/chat",
}),
});
41 changes: 31 additions & 10 deletions src/app/components/login/tinyLogin.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
"use client"

import { useEffect } from 'react';
import { useRouter } from 'next/navigation';
import styles from "./login.module.scss";
import { redirect } from "next/navigation";
import { useAuthApi } from '@/app/hooks/useAuthApi';

export default function TinyLogin(text: {label:string}) {
export default function TinyLogin({ label }: { label: string }) {
const { user, error, fetchToken } = useAuthApi();
const router = useRouter();

if (error) return <div>{error.message}</div>;
if (user){
fetchToken().catch(console.error);
redirect('/chat');
}
useEffect(() => {
if (user) {
fetchToken().catch(console.error);
router.push('/chat'); // Internal app navigation is fine with router.push
}
}, [user, fetchToken, router]);

const handleAuth = (action: 'login' | 'logout') => (e: React.MouseEvent) => {
if (error) return <div className={styles.error}>{error.message}</div>;

const handleAuth = (action: 'login' | 'logout' | 'signup') => (e: React.MouseEvent) => {
e.preventDefault();
if (action === 'login') {router.push(`/api/auth/login?returnTo=/chat`)} else {router.push(`/api/auth/logout`)}

if (action === 'login') {
// This hits the default login handler
window.location.assign('/api/auth/login?returnTo=/chat');
} else if (action === 'signup') {
// This hits your specific signup handler defined in your GET route
window.location.assign('/api/auth/signup');
} else {
window.location.assign('/api/auth/logout');
}
};

// If user is already logged in, we don't need to show the login button
if (user) return null;

return (
<div>
<button className={styles.tinyLogin} onClick={handleAuth('login')}>{text.label}</button>
<button
className={styles.tinyLogin}
onClick={handleAuth('login')}
>
{label}
</button>
</div>
);

}
26 changes: 0 additions & 26 deletions web_extension/Veracity_Extension/.gitignore

This file was deleted.

82 changes: 0 additions & 82 deletions web_extension/Veracity_Extension/README.md

This file was deleted.

10 changes: 0 additions & 10 deletions web_extension/Veracity_Extension/next.config.js

This file was deleted.

Loading