"use client" import React, { useState } from "react" import { Input } from "@/components/ui/input" import { Button } from "@/components/ui/button" import { Label } from "@/components/ui/label" import { Key, Loader2 } from "lucide-react" import Link from "next/link" import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog" export function ChangeAuthentikPassword() { const [newPassword, setNewPassword] = useState("") const [loading, setLoading] = useState(false) const [message, setMessage] = useState(null) const [open, setOpen] = useState(false) const handlePasswordChange = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setMessage(null) try { const response = await fetch("/api/auth/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) // Close dialog after change setTimeout(() => { setOpen(false) setNewPassword("") }, 1500) // TODO: Show a toast that password was changed } 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 Your Password This only applies to your Authentik account. Make sure it's secure, and consider using LibreCloud Pass to keep it safe!
setNewPassword(e.target.value)} className="mt-1.5" />

Password must be at least 8 characters long.

{message && (

{message}

)}
) } export default ChangeAuthentikPassword