- Updated the registration flow to check if the first admin account has been created, preventing further public registrations. - Introduced `is_first_admin_setup_available` function to determine registration availability. - Modified the `/register` and `/login` pages to redirect based on the setup state. - Enhanced the user creation process to handle internal admin accounts correctly. - Added migration script to enforce the new registration rules in the database. - Refactored chat API to improve message handling and context building. - Updated dashboard and settings components for better state management. - Improved error handling and user feedback across various components.
22 lines
586 B
TypeScript
22 lines
586 B
TypeScript
import { createClient } from "@/lib/supabase/server";
|
||
|
||
type FirstAdminSetupState = {
|
||
available: boolean;
|
||
errorMessage?: string;
|
||
};
|
||
|
||
export async function getFirstAdminSetupState(): Promise<FirstAdminSetupState> {
|
||
const supabase = await createClient();
|
||
const { data, error } = await supabase.rpc("is_first_admin_setup_available");
|
||
|
||
if (error) {
|
||
return {
|
||
available: false,
|
||
errorMessage:
|
||
"İlk kurulum kontrolü yapılamadı. 0009 kayıt kilidi migration dosyasını çalıştırdığından emin ol.",
|
||
};
|
||
}
|
||
|
||
return { available: Boolean(data) };
|
||
}
|