From 2b2084c7bd1c9e4092e74d99b673728a89f0d267 Mon Sep 17 00:00:00 2001 From: Thareek Anvar M Date: Tue, 28 Feb 2023 09:38:53 +0530 Subject: [PATCH] changes --- web/src/pages/Auth.tsx | 90 +++++++++++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 19 deletions(-) diff --git a/web/src/pages/Auth.tsx b/web/src/pages/Auth.tsx index 59e201b4..7b6dbb24 100644 --- a/web/src/pages/Auth.tsx +++ b/web/src/pages/Auth.tsx @@ -20,7 +20,9 @@ const Auth = () => { const mode = systemStatus.profile.mode; const [username, setUsername] = useState(mode === "demo" ? "demohero" : ""); const [password, setPassword] = useState(mode === "demo" ? "secret" : ""); - const [identityProviderList, setIdentityProviderList] = useState([]); + const [identityProviderList, setIdentityProviderList] = useState< + IdentityProvider[] + >([]); useEffect(() => { userStore.doSignOut().catch(); @@ -33,12 +35,16 @@ const Auth = () => { fetchIdentityProviderList(); }, []); - const handleUsernameInputChanged = (e: React.ChangeEvent) => { + const handleUsernameInputChanged = ( + e: React.ChangeEvent + ) => { const text = e.target.value as string; setUsername(text); }; - const handlePasswordInputChanged = (e: React.ChangeEvent) => { + const handlePasswordInputChanged = ( + e: React.ChangeEvent + ) => { const text = e.target.value as string; setPassword(text); }; @@ -63,11 +69,11 @@ const Auth = () => { if (user) { window.location.href = "/"; } else { - toastHelper.error(t("message.login-failed"),5000); + toastHelper.error(t("message.login-failed")); } } catch (error: any) { console.error(error); - toastHelper.error(error.response.data.error,5000); + toastHelper.error(error.response.data.error); } actionBtnLoadingState.setFinish(); }; @@ -99,7 +105,9 @@ const Auth = () => { } }; - const handleSignInWithIdentityProvider = async (identityProvider: IdentityProvider) => { + const handleSignInWithIdentityProvider = async ( + identityProvider: IdentityProvider + ) => { const stateQueryParameter = `auth.signin.${identityProvider.name}-${identityProvider.id}`; if (identityProvider.type === "OAUTH2") { const redirectUri = absolutifyLink("/auth/callback"); @@ -119,18 +127,38 @@ const Auth = () => {
- +

{systemStatus.customizedProfile.name}

-

{systemStatus.customizedProfile.description || t("slogan")}

+

+ {systemStatus.customizedProfile.description || t("slogan")} +

-
+
- {t("common.username")} - + + {t("common.username")} + +
- {t("common.password")} + + {t("common.password")} + {
{systemStatus?.host ? ( <> - {actionBtnLoadingState.isLoading && } + {actionBtnLoadingState.isLoading && ( + + )} {systemStatus?.allowSignUp && ( <> - / )} - ) : ( <> - @@ -176,7 +221,9 @@ const Auth = () => { color="neutral" className="w-full" size="md" - onClick={() => handleSignInWithIdentityProvider(identityProvider)} + onClick={() => + handleSignInWithIdentityProvider(identityProvider) + } > Sign in with {identityProvider.name} @@ -184,11 +231,16 @@ const Auth = () => {
)} - {!systemStatus?.host &&

{t("auth.host-tip")}

} + {!systemStatus?.host && ( +

{t("auth.host-tip")}

+ )}
- +