Login:OAuth2: fix consent change user
This commit is contained in:
parent
6c78635489
commit
280400f0a2
@ -76,6 +76,9 @@ const Login: React.FC<ILoginProps> = ({
|
|||||||
oauth?.client || ({} as IClientProps)
|
oauth?.client || ({} as IClientProps)
|
||||||
);
|
);
|
||||||
const [self, setSelf] = useState(oauth?.self || ({} as ISelf));
|
const [self, setSelf] = useState(oauth?.self || ({} as ISelf));
|
||||||
|
const [hashSettings, setHashSettings] = useState<null | PasswordHashType>(
|
||||||
|
null
|
||||||
|
);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
enabledJoin,
|
enabledJoin,
|
||||||
@ -237,6 +240,8 @@ const Login: React.FC<ILoginProps> = ({
|
|||||||
if (!mounted) return <></>;
|
if (!mounted) return <></>;
|
||||||
if (isRestoringPortal) return <></>;
|
if (isRestoringPortal) return <></>;
|
||||||
|
|
||||||
|
console.log(portalSettings);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoginFormWrapper
|
<LoginFormWrapper
|
||||||
id="login-page"
|
id="login-page"
|
||||||
@ -260,6 +265,8 @@ const Login: React.FC<ILoginProps> = ({
|
|||||||
<Consent
|
<Consent
|
||||||
oauth={{ ...oauth, scopes, client: oauthClient, self }}
|
oauth={{ ...oauth, scopes, client: oauthClient, self }}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
|
hashSettings={portalSettings?.passwordHash || hashSettings}
|
||||||
|
setHashSettings={setHashSettings}
|
||||||
setIsConsentScreen={setIsConsentPage}
|
setIsConsentScreen={setIsConsentPage}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
@ -296,7 +303,7 @@ const Login: React.FC<ILoginProps> = ({
|
|||||||
recaptchaPublicKey={portalSettings?.recaptchaPublicKey}
|
recaptchaPublicKey={portalSettings?.recaptchaPublicKey}
|
||||||
isDesktop={!!isDesktopEditor}
|
isDesktop={!!isDesktopEditor}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
hashSettings={portalSettings?.passwordHash}
|
hashSettings={portalSettings?.passwordHash || hashSettings}
|
||||||
setIsLoading={setIsLoading}
|
setIsLoading={setIsLoading}
|
||||||
openRecoverDialog={openRecoverDialog}
|
openRecoverDialog={openRecoverDialog}
|
||||||
match={match}
|
match={match}
|
||||||
|
@ -69,10 +69,18 @@ StyledFormWrapper.defaultProps = { theme: Base };
|
|||||||
interface IConsentProps {
|
interface IConsentProps {
|
||||||
oauth: IOAuthState;
|
oauth: IOAuthState;
|
||||||
theme: IUserTheme;
|
theme: IUserTheme;
|
||||||
|
hashSettings: null | PasswordHashType;
|
||||||
|
setHashSettings: (hashSettings: PasswordHashType | null) => void;
|
||||||
setIsConsentScreen: (value: boolean) => void;
|
setIsConsentScreen: (value: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Consent = ({ oauth, theme, setIsConsentScreen }: IConsentProps) => {
|
const Consent = ({
|
||||||
|
oauth,
|
||||||
|
theme,
|
||||||
|
setIsConsentScreen,
|
||||||
|
hashSettings,
|
||||||
|
setHashSettings,
|
||||||
|
}: IConsentProps) => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
@ -107,8 +115,16 @@ const Consent = ({ oauth, theme, setIsConsentScreen }: IConsentProps) => {
|
|||||||
window.location.href = oauth.client.websiteUrl;
|
window.location.href = oauth.client.websiteUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChangeUserClick = () => {
|
const onChangeUserClick = async () => {
|
||||||
api.user.logout();
|
await api.user.logout();
|
||||||
|
if (!hashSettings) {
|
||||||
|
const portalSettings = await api.settings.getSettings();
|
||||||
|
|
||||||
|
console.log(portalSettings);
|
||||||
|
|
||||||
|
setHashSettings(portalSettings.passwordHash);
|
||||||
|
}
|
||||||
|
|
||||||
setIsConsentScreen(false);
|
setIsConsentScreen(false);
|
||||||
navigate(`/login/${location.search}`);
|
navigate(`/login/${location.search}`);
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ import { IClientProps, IScope } from "@docspace/common/utils/oauth/interfaces";
|
|||||||
interface ILoginFormProps {
|
interface ILoginFormProps {
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
setIsLoading: (isLoading: boolean) => void;
|
setIsLoading: (isLoading: boolean) => void;
|
||||||
hashSettings: PasswordHashType;
|
hashSettings: PasswordHashType | null;
|
||||||
isDesktop: boolean;
|
isDesktop: boolean;
|
||||||
match: MatchType;
|
match: MatchType;
|
||||||
openRecoverDialog: () => void;
|
openRecoverDialog: () => void;
|
||||||
@ -221,6 +221,7 @@ const LoginForm: React.FC<ILoginFormProps> = ({
|
|||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
|
console.log(pass, hashSettings);
|
||||||
const hash = createPasswordHash(pass, hashSettings);
|
const hash = createPasswordHash(pass, hashSettings);
|
||||||
|
|
||||||
isDesktop && checkPwd();
|
isDesktop && checkPwd();
|
||||||
|
Loading…
Reference in New Issue
Block a user