import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card" import { AlertCircle, CheckCircleIcon, XCircleIcon, Loader2, ShieldCheck, Search, Lightbulb } from "lucide-react" import { useState } from "react" import { SiAuthentik } from "react-icons/si" import { type SecurityResults } from "@/app/api/users/security/route" export const SecurityTab = () => { const [scanning, setScanning] = useState(false) const [scanResults, setScanResults] = useState(null) const [error, setError] = useState(null) const scanAcc = async () => { setScanning(true) try { const res = await fetch("/api/users/security") const data = await res.json() setScanResults(data) setScanning(false) } catch (error) { console.error(error) setError(error instanceof Error ? error.message : "An unknown error occurred") setScanning(false) } } // If password was changed over 3 months ago, this will be true const shouldResetPass = scanResults?.authentik?.passwordChangeDate && scanResults?.authentik?.passwordChangeDate < new Date(Date.now() - 90 * 24 * 60 * 60 * 1000) // If user has no 2FA methods setup, this will be true const insufficient2FA = scanResults?.authentik?.authenticators.length === 0 return (
Account Security Scan Evaluate the security of your account with a simple button click! {error ? (

Error

{error}

) : scanResults ? ( <>

Authentik

{shouldResetPass ? (

Password last changed {"on " + (scanResults?.authentik?.passwordChangeDate ? new Date(scanResults.authentik.passwordChangeDate).toLocaleDateString() : "never")}

) : (

Password last changed {"on " + (scanResults?.authentik?.passwordChangeDate ? new Date(scanResults.authentik.passwordChangeDate).toLocaleDateString() : "never")}

)} {insufficient2FA ? (

No 2FA methods setup

) : (

{scanResults?.authentik?.authenticators.length} two-factor authentication methods setup

)} ) : ( <> {scanning ? ( ) : ( )} )}
Recommendations Steps you can take to improve your account's security
  • Enable Two-Factor Authentication
  • Use a strong and unique password
  • Always make sure the URL matches librecloud.cc
  • https://librecloud.cc
    https://libre-cloud-login.com
) }