Skip to content

Commit d7dda82

Browse files
committed
feat: log user out when delete profile
1 parent 19a73be commit d7dda82

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

frontend/src/app/api/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const FetchAuth = {
3838
const res = await fetch(url, options);
3939
if (!res.ok) {
4040
console.log(res);
41-
throw Error();
41+
// throw Error();
4242
}
4343
return res;
4444
},

frontend/src/app/settings/page.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ import {
1010
import useLogin from "../hooks/useLogin";
1111
import { message } from "antd";
1212
import { useMutation } from "@tanstack/react-query";
13+
import { getAuth, signOut } from "firebase/auth";
14+
import { useRouter } from "next/navigation";
1315

1416
const SettingPage = () => {
1517
const user = useLogin();
18+
const router = useRouter();
1619

1720
const deleteProfileMutation = useMutation(async () => deleteProfileUrl(), {
1821
onSuccess: () => {
1922
closeModal("delete_modal");
2023
api.open({
2124
type: "success",
22-
content: "Successfully deleted profile!",
25+
content: "Successfully deleted profile! Logging you out...",
2326
});
27+
const auth = getAuth();
28+
setTimeout(() => {
29+
signOut(auth);
30+
router.push("/");
31+
}, 2000);
2432
},
2533
onError: (e) => {
2634
api.open({

0 commit comments

Comments
 (0)