Skip to content

Commit

Permalink
fixed invalid login routing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
adhi0331 committed Apr 8, 2024
1 parent 62fa369 commit ce4ac44
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 5 deletions.
122 changes: 120 additions & 2 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions frontend/src/firebase/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ export const initFirebase = () => {

return { app, auth };
};

const { app, auth } = initFirebase();

export { app, auth };
5 changes: 2 additions & 3 deletions frontend/src/pages/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { GET } from "@/api/requests";
import Landing from "@/components/Landing";
import { Textfield } from "@/components/Textfield";
import { Button } from "@/components/ui/button";
import { initFirebase } from "@/firebase/firebase";
import { auth } from "@/firebase/firebase";
import { useWindowSize } from "@/hooks/useWindowSize";
import { cn } from "@/lib/utils";

Expand All @@ -24,7 +24,6 @@ export default function Login() {

const [firebaseError, setFirebaseError] = useState("");

const { auth } = initFirebase();
const router = useRouter();

const login = async (email: string, password: string) => {
Expand Down Expand Up @@ -59,11 +58,11 @@ export default function Login() {
login(data.email as string, data.password as string)
.then((token: string) => {
void sendTokenToBackend(token);
router.push("/home");
})
.catch((_) => {
setFirebaseError("Invalid login. Please check your username and password.");
});
router.push("/home");
};
const { isMobile, isTablet } = useWindowSize();

Expand Down

0 comments on commit ce4ac44

Please sign in to comment.