Check if user exists on login

This commit is contained in:
headlesdev
2025-05-17 15:37:25 +02:00
parent eb72e07d7f
commit 6c0edecabf
3 changed files with 300 additions and 2 deletions

View File

@@ -1,7 +1,25 @@
"use client";
import Image from "next/image"
import Link from "next/link"
import {useEffect} from "react";
import { useRouter } from "next/navigation";
import axios from "axios";
export default function LoginPage() {
const router = useRouter();
useEffect(() => {
const init = async () => {
const response = await axios.get("/api/user/init");
if (response.data.message === "No users found") {
router.push("/setup");
}
};
init();
}, []);
return (
<div className="min-h-screen flex flex-col lg:flex-row">
<div className="flex-1 flex items-center justify-center p-6 lg:p-10">