π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-2263] fix: god mode wrong credentials error message banner (#5407)
Anmol Singh Bhatiad802316c5cbb
diff --git a/admin/core/components/authentication/auth-banner.tsx b/admin/core/components/authentication/auth-banner.tsxnew file mode 100644index 0000000000..191d7a0a77--- /dev/null+++ b/admin/core/components/authentication/auth-banner.tsx@@ -0,0 +1,29 @@+import { FC } from "react";+import { Info, X } from "lucide-react";+// helpers+import { TAuthErrorInfo } from "@/helpers/authentication.helper";++type TAuthBanner = {+ bannerData: TAuthErrorInfo | undefined;+ handleBannerData?: (bannerData: TAuthErrorInfo | undefined) => void;+};++export const AuthBanner: FC<TAuthBanner> = (props) => {+ const { bannerData, handleBannerData } = props;++ if (!bannerData) return <></>;+ return (+ <div className="relative flex items-center p-2 rounded-md gap-2 border border-custom-primary-100/50 bg-custom-primary-100/10">+ <div className="w-4 h-4 flex-shrink-0 relative flex justify-center items-center">+ <Info size={16} className="text-custom-primary-100" />+ </div>+ <div className="w-full text-sm font-medium text-custom-primary-100">{bannerData?.message}</div>+ <div+ className="relative ml-auto w-6 h-6 rounded-sm flex justify-center items-center transition-all cursor-pointer hover:bg-custom-primary-100/20 text-custom-primary-100/80"+ onClick={() => handleBannerData && handleBannerData(undefined)}+ >+ <X className="w-4 h-4 flex-shrink-0" />+ </div>+ </div>+ );+};diff --git a/admin/core/components/authentication/index.ts b/admin/core/components/authentication/index.tsindex 2c13b77289..d189a727ba 100644--- a/admin/core/components/authentication/index.ts+++ b/admin/core/components/authentication/index.ts@@ -1,3 +1,4 @@+export * from "./auth-banner";export * from "./email-config-switch";export * from "./password-config-switch";export * from "./authentication-method-card";diff --git a/admin/core/components/login/sign-in-form.tsx b/admin/core/components/login/sign-in-form.tsxindex 30d7011e7f..aa67d4936e 100644--- a/admin/core/components/login/sign-in-form.tsx+++ b/admin/core/components/login/sign-in-form.tsx@@ -8,8 +8,16 @@ import { Button, Input, Spinner } from "@plane/ui";// componentsimport { Banner } from "@/components/common";// helpers+import {+ authErrorHandler,+ EAuthenticationErrorCodes,+ EErrorAlertType,+ TAuthErrorInfo,+} from "@/helpers/authentication.helper";+import { API_BASE_URL } from "@/helpers/common.helper";import { AuthService } from "@/services/auth.service";+import { AuthBanner } from "../authentication";// ui// icons@@ -53,6 +61,7 @@ export const InstanceSignInForm: FC = (props) => {const [csrfToken, setCsrfToken] = useState<string | undefined>(undefined);const [formData, setFormData] = useState<TFormData>(defaultFromData);const [isSubmitting, setIsSubmitting] = useState(false);+ const [errorInfo, setErrorInfo] = useState<TAuthErrorInfo | undefined>(undefined);const handleFormChange = (key: keyof TFormData, value: string | boolean) =>setFormData((prev) => ({ ...prev, [key]: value }));@@ -91,6 +100,15 @@ export const InstanceSignInForm: FC = (props) => {[formData.email, formData.password, isSubmitting]);+ useEffect(() => {+ if (errorCode) {+ const errorDetail = authErrorHandler(errorCode?.toString() as EAuthenticationErrorCodes);+ if (errorDetail) {+ setErrorInfo(errorDetail);+ }+ }+ }, [errorCode]);+return (<div className="flex-grow container mx-auto max-w-lg px-10 lg:max-w-md lg:px-5 py-10 lg:pt-28 transition-all"><div className="relative flex flex-col space-y-6">@@ -103,7 +121,11 @@ export const InstanceSignInForm: FC = (props) => {</p></div>- {errorData.type && errorData?.message && <Banner type="error" message={errorData?.message} />}+ {errorData.type && errorData?.message ? (+ <Banner type="error" message={errorData?.message} />+ ) : (+ <>{errorInfo && <AuthBanner bannerData={errorInfo} handleBannerData={(value) => setErrorInfo(value)} />}</>+ )}<formclassName="space-y-4"