"use client" import React, { useState } from "react" import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { Label } from "@/components/ui/label" import { Mail, Key, Loader } from "lucide-react" export function ChangePassword() { const [newPassword, setNewPassword] = useState(""); const [loading, setLoading] = useState(false); const [message, setMessage] = useState(null); const handlePasswordChange = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setMessage(null); try { const response = await fetch("/api/mail/password", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ password: newPassword }), }); const resData = await response.json(); if (response.ok && resData.success) { setMessage("Password Updated"); setLoading(false); } else if (resData.error) { setMessage(resData.error); setLoading(false); } else { setMessage("[1] Failed to Update"); setLoading(false); } } catch (error) { console.log(error) setMessage("[2] Failed to Update"); setLoading(false); } }; return ( Change Email Password Please note, this will NOT change your Authentik password. {/* TODO: please tell me you added password resets to authentik by now */}
setNewPassword(e.target.value)} className="mt-1.5" />
{message &&

{message}

}
); } export default ChangePassword;