diff --git a/packages/login/src/client/components/Login.tsx b/packages/login/src/client/components/Login.tsx index f0fc70d5f3..53087779cf 100644 --- a/packages/login/src/client/components/Login.tsx +++ b/packages/login/src/client/components/Login.tsx @@ -76,6 +76,9 @@ const Login: React.FC = ({ oauth?.client || ({} as IClientProps) ); const [self, setSelf] = useState(oauth?.self || ({} as ISelf)); + const [hashSettings, setHashSettings] = useState( + null + ); const { enabledJoin, @@ -237,6 +240,8 @@ const Login: React.FC = ({ if (!mounted) return <>; if (isRestoringPortal) return <>; + console.log(portalSettings); + return ( = ({ ) : ( @@ -296,7 +303,7 @@ const Login: React.FC = ({ recaptchaPublicKey={portalSettings?.recaptchaPublicKey} isDesktop={!!isDesktopEditor} isLoading={isLoading} - hashSettings={portalSettings?.passwordHash} + hashSettings={portalSettings?.passwordHash || hashSettings} setIsLoading={setIsLoading} openRecoverDialog={openRecoverDialog} match={match} diff --git a/packages/login/src/client/components/sub-components/Consent.tsx b/packages/login/src/client/components/sub-components/Consent.tsx index 2090c8c929..e109f698f9 100644 --- a/packages/login/src/client/components/sub-components/Consent.tsx +++ b/packages/login/src/client/components/sub-components/Consent.tsx @@ -69,10 +69,18 @@ StyledFormWrapper.defaultProps = { theme: Base }; interface IConsentProps { oauth: IOAuthState; theme: IUserTheme; + hashSettings: null | PasswordHashType; + setHashSettings: (hashSettings: PasswordHashType | null) => void; setIsConsentScreen: (value: boolean) => void; } -const Consent = ({ oauth, theme, setIsConsentScreen }: IConsentProps) => { +const Consent = ({ + oauth, + theme, + setIsConsentScreen, + hashSettings, + setHashSettings, +}: IConsentProps) => { const navigate = useNavigate(); const location = useLocation(); @@ -107,8 +115,16 @@ const Consent = ({ oauth, theme, setIsConsentScreen }: IConsentProps) => { window.location.href = oauth.client.websiteUrl; }; - const onChangeUserClick = () => { - api.user.logout(); + const onChangeUserClick = async () => { + await api.user.logout(); + if (!hashSettings) { + const portalSettings = await api.settings.getSettings(); + + console.log(portalSettings); + + setHashSettings(portalSettings.passwordHash); + } + setIsConsentScreen(false); navigate(`/login/${location.search}`); }; diff --git a/packages/login/src/client/components/sub-components/LoginForm.tsx b/packages/login/src/client/components/sub-components/LoginForm.tsx index 367fec80a2..4cfa2ee1ca 100644 --- a/packages/login/src/client/components/sub-components/LoginForm.tsx +++ b/packages/login/src/client/components/sub-components/LoginForm.tsx @@ -37,7 +37,7 @@ import { IClientProps, IScope } from "@docspace/common/utils/oauth/interfaces"; interface ILoginFormProps { isLoading: boolean; setIsLoading: (isLoading: boolean) => void; - hashSettings: PasswordHashType; + hashSettings: PasswordHashType | null; isDesktop: boolean; match: MatchType; openRecoverDialog: () => void; @@ -221,6 +221,7 @@ const LoginForm: React.FC = ({ setIsLoading(true); + console.log(pass, hashSettings); const hash = createPasswordHash(pass, hashSettings); isDesktop && checkPwd();