"use client"; import { useState } from "react"; import Image from "next/image"; import { useTheme } from "next-themes"; import useSWR from "swr"; import { observer } from "mobx-react-lite"; import { Mails, KeyRound } from "lucide-react"; import { Loader, setPromiseToast } from "@plane/ui"; import { TInstanceConfigurationKeys } from "@plane/types"; // components import { AuthenticationMethodCard, EmailCodesConfiguration, PasswordLoginConfiguration } from "./components"; import { GoogleConfiguration } from "./google/components"; import { GithubConfiguration } from "./github/components"; import { PageHeader } from "@/components/core"; // hooks import { useInstance } from "@/hooks"; // helpers import { resolveGeneralTheme } from "@/helpers/common.helper"; // images import GoogleLogo from "@/public/logos/google-logo.svg"; import githubLightModeImage from "@/public/logos/github-black.png"; import githubDarkModeImage from "@/public/logos/github-white.png"; type TInstanceAuthenticationMethodCard = { key: string; name: string; description: string; icon: JSX.Element; config: JSX.Element; }; const InstanceAuthenticationPage = observer(() => { // store const { fetchInstanceConfigurations, formattedConfig, updateInstanceConfigurations } = useInstance(); useSWR("INSTANCE_CONFIGURATIONS", () => fetchInstanceConfigurations()); // state const [isSubmitting, setIsSubmitting] = useState(false); // theme const { resolvedTheme } = useTheme(); const updateConfig = async (key: TInstanceConfigurationKeys, value: string) => { setIsSubmitting(true); const payload = { [key]: value, }; const updateConfigPromise = updateInstanceConfigurations(payload); setPromiseToast(updateConfigPromise, { loading: "Saving Configuration...", success: { title: "Success", message: () => "Configuration saved successfully", }, error: { title: "Error", message: () => "Failed to save configuration", }, }); await updateConfigPromise .then(() => { setIsSubmitting(false); }) .catch((err) => { console.error(err); setIsSubmitting(false); }); }; // Authentication methods const authenticationMethodsCard: TInstanceAuthenticationMethodCard[] = [ { key: "email-codes", name: "Email codes", description: "Login or sign up using codes sent via emails. You need to have email setup here and enabled.", icon: , config: , }, { key: "password-login", name: "Password based login", description: "Allow members to create accounts with passwords for emails to sign in.", icon: , config: , }, { key: "google", name: "Google", description: "Allow members to login or sign up to plane with their Google accounts.", icon: Google Logo, config: , }, { key: "github", name: "Github", description: "Allow members to login or sign up to plane with their Github accounts.", icon: ( GitHub Logo ), config: , }, ]; return ( <>
Manage authentication for your instance
Configure authentication modes for your team and restrict sign ups to be invite only.
{formattedConfig ? (
Authentication modes
{authenticationMethodsCard.map((method) => ( ))}
) : ( )}
); }); export default InstanceAuthenticationPage;