Spaces:
Sleeping
Sleeping
FauziIsyrinApridal commited on
Commit ·
445f8f2
1
Parent(s): ef0f7a3
revisi 6
Browse files
components/ResetPasswordForm.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import { Button } from "./ui/button";
|
|
| 7 |
import { Label } from "./ui/label";
|
| 8 |
import { useState } from "react";
|
| 9 |
import { createClient } from "@/utils/supabase/client";
|
|
|
|
| 10 |
|
| 11 |
const schema = z
|
| 12 |
.object({
|
|
@@ -22,6 +23,7 @@ type FormFields = z.infer<typeof schema>;
|
|
| 22 |
|
| 23 |
export default function ResetPasswordForm() {
|
| 24 |
const supabase = createClient();
|
|
|
|
| 25 |
const [successMsg, setSuccessMsg] = useState<string | null>(null);
|
| 26 |
const {
|
| 27 |
register,
|
|
@@ -37,7 +39,11 @@ export default function ResetPasswordForm() {
|
|
| 37 |
setError("root", { message: "Gagal mengubah password. Coba lagi." });
|
| 38 |
return;
|
| 39 |
}
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
};
|
| 42 |
|
| 43 |
return (
|
|
|
|
| 7 |
import { Label } from "./ui/label";
|
| 8 |
import { useState } from "react";
|
| 9 |
import { createClient } from "@/utils/supabase/client";
|
| 10 |
+
import { useRouter } from "next/navigation";
|
| 11 |
|
| 12 |
const schema = z
|
| 13 |
.object({
|
|
|
|
| 23 |
|
| 24 |
export default function ResetPasswordForm() {
|
| 25 |
const supabase = createClient();
|
| 26 |
+
const router = useRouter();
|
| 27 |
const [successMsg, setSuccessMsg] = useState<string | null>(null);
|
| 28 |
const {
|
| 29 |
register,
|
|
|
|
| 39 |
setError("root", { message: "Gagal mengubah password. Coba lagi." });
|
| 40 |
return;
|
| 41 |
}
|
| 42 |
+
// Pastikan sesi lama tidak tersisa
|
| 43 |
+
await supabase.auth.signOut();
|
| 44 |
+
// Opsi: tampilkan pesan singkat sebelum redirect
|
| 45 |
+
setSuccessMsg("Password berhasil diubah. Mengarahkan ke halaman login...");
|
| 46 |
+
router.replace("/login");
|
| 47 |
};
|
| 48 |
|
| 49 |
return (
|