Spaces:
Sleeping
Sleeping
"use server"; | |
// Server action kept minimal; reset is better done on client using the recovery session token. | |
// Provided for completeness if needed by API routes in future. | |
import { createClient } from "@/utils/supabase/server"; | |
export type ResetResult = { ok: true; message: string } | { ok: false; message: string }; | |
export async function resetPasswordServer(password: string): Promise<ResetResult> { | |
if (!password || password.length < 8) { | |
return { ok: false, message: "Password minimal 8 karakter" }; | |
} | |
const supabase = createClient(); | |
const { error } = await supabase.auth.updateUser({ password }); | |
if (error) { | |
return { ok: false, message: "Gagal memperbarui password." }; | |
} | |
return { ok: true, message: "Password berhasil diubah." }; | |
} | |